|
|
@ -24,11 +24,22 @@ func WritePid(id string) (err error) { |
|
|
|
|
|
|
|
|
|
|
|
func WritePidById(id string, path string) error { |
|
|
|
func WritePidById(id string, path string) error { |
|
|
|
var dir string |
|
|
|
var dir string |
|
|
|
|
|
|
|
var err error |
|
|
|
if path == "" { |
|
|
|
if path == "" { |
|
|
|
dir, _ = os.Getwd() |
|
|
|
if dir, err = os.Getwd(); err != nil { |
|
|
|
|
|
|
|
return err |
|
|
|
|
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
dir = path |
|
|
|
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" |
|
|
|
pidfile := filepath.Join(dir, id) + ".pid" |
|
|
|
if err := WritePid(pidfile); err != nil { |
|
|
|
if err := WritePid(pidfile); err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
|