mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #27690 from Microsoft/service
mkdirall on the PID file path
This commit is contained in:
commit
0dfa306cdd
1 changed files with 7 additions and 0 deletions
|
@ -7,8 +7,11 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/docker/docker/pkg/system"
|
||||||
)
|
)
|
||||||
|
|
||||||
// PIDFile is a file used to store the process ID of a running process.
|
// PIDFile is a file used to store the process ID of a running process.
|
||||||
|
@ -33,6 +36,10 @@ func New(path string) (*PIDFile, error) {
|
||||||
if err := checkPIDFileAlreadyExists(path); err != nil {
|
if err := checkPIDFileAlreadyExists(path); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
// Note MkdirAll returns nil if a directory already exists
|
||||||
|
if err := system.MkdirAll(filepath.Dir(path), os.FileMode(0755)); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
if err := ioutil.WriteFile(path, []byte(fmt.Sprintf("%d", os.Getpid())), 0644); err != nil {
|
if err := ioutil.WriteFile(path, []byte(fmt.Sprintf("%d", os.Getpid())), 0644); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue