|
|
|
@ -24,11 +24,22 @@ func WritePid(id string) (err error) { |
|
|
|
|
|
|
|
|
|
func WritePidById(id string, path string) error { |
|
|
|
|
var dir string |
|
|
|
|
var err error |
|
|
|
|
if path == "" { |
|
|
|
|
dir, _ = os.Getwd() |
|
|
|
|
if dir, err = os.Getwd(); err != nil { |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
dir = path |
|
|
|
|
if _, err := os.Stat(dir); os.IsNotExist(err) { |
|
|
|
|
os.Mkdir(dir, os.ModePerm) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if dir, err = filepath.Abs(dir); err != nil { |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pidfile := filepath.Join(dir, id) + ".pid" |
|
|
|
|
if err := WritePid(pidfile); err != nil { |
|
|
|
|
return err |
|
|
|
|