mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-08 01:58:34 +08:00
Fix runtime path created by multiple processes (#11966)
Signed-off-by: dragondriver <jiquan.long@zilliz.com>
This commit is contained in:
parent
ba9977951a
commit
cc0d6dc6fd
17
cmd/main.go
17
cmd/main.go
@ -142,17 +142,14 @@ func stopPid(filename string, runtimeDir string) error {
|
||||
}
|
||||
|
||||
func makeRuntimeDir(dir string) error {
|
||||
st, err := os.Stat(dir)
|
||||
if os.IsNotExist(err) {
|
||||
err = os.Mkdir(dir, 0755)
|
||||
if err != nil {
|
||||
return fmt.Errorf("create runtime dir %s failed", dir)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if !st.IsDir() {
|
||||
return fmt.Errorf("%s is not directory", dir)
|
||||
perm := os.FileMode(0755)
|
||||
// os.MkdirAll equal to `mkdir -p`
|
||||
err := os.MkdirAll(dir, perm)
|
||||
if err != nil {
|
||||
// err will be raised only when dir exists and dir is a file instead of a directory.
|
||||
return fmt.Errorf("create runtime dir %s failed, err: %s", dir, err.Error())
|
||||
}
|
||||
|
||||
tmpFile, err := ioutil.TempFile(dir, "tmp")
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user