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 {
|
func makeRuntimeDir(dir string) error {
|
||||||
st, err := os.Stat(dir)
|
perm := os.FileMode(0755)
|
||||||
if os.IsNotExist(err) {
|
// os.MkdirAll equal to `mkdir -p`
|
||||||
err = os.Mkdir(dir, 0755)
|
err := os.MkdirAll(dir, perm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("create runtime dir %s failed", dir)
|
// 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())
|
||||||
return nil
|
|
||||||
}
|
|
||||||
if !st.IsDir() {
|
|
||||||
return fmt.Errorf("%s is not directory", dir)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpFile, err := ioutil.TempFile(dir, "tmp")
|
tmpFile, err := ioutil.TempFile(dir, "tmp")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user