Merge pull request #28 from alibaba/github-develop

modify pid
v4
Vinllen Chen 6 years ago committed by GitHub
commit 52bed9405a
  1. 3
      conf/redis-shake.conf
  2. 13
      src/redis-shake/common/mix.go

@ -4,7 +4,8 @@
id = redis-shake id = redis-shake
# log file,日志文件,不配置将打印到stdout (e.g. /var/log/redis-shake.log ) # log file,日志文件,不配置将打印到stdout (e.g. /var/log/redis-shake.log )
log_file = log_file =
# pid path,进程文件存储地址,不配置将输出到项目目录下 (e.g. /var/run/ ) # pid path,进程文件存储地址,不配置将输出到项目目录下(e.g. /var/run/), 注意这个是目录,
# 真正的pid是`{pid_path}/{id}.pid`
pid_path = pid_path =
# pprof port # pprof port

@ -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

Loading…
Cancel
Save