6

This may seem to be a repeated question but it is not. I found some articles on it where start-stop-daemon doesn't create a PID file. But in my case, I have already created the PID file. I execute this command on my server to start Nginx:

/mnt/nginx/logs/nginx.pid
start-stop-daemon --start --quiet --pidfile /mnt/nginx/logs/nginx.pid --exec /usr/local/sbin/nginx

The PID file is already present but still the start-stop-daemon doesn't write to the file. I even tried to use the --make-pidfile option but then the start-stop-daemon writes wrong pid to the file.

4

1 回答 1

7

--make-pidfile选项是必需的。写“错误的pid”的原因start-stop-daemonnginx分叉。这在start-stop-daemon手册页中有说明:

   -m, --make-pidfile
          Used when starting a program that does not create  its  own  pid
          file.  This  option  will make start-stop-daemon create the file
          referenced with --pidfile and place the pid into it just  before
          executing  the  process. Note, the file will not be removed when
          stopping the program.  NOTE: This feature may not  work  in  all
          cases.  Most  notably when the program being executed forks from
          its main process. Because of this, it  is  usually  only  useful
          when combined with the --background option.

(参见重新分叉的部分。)

您需要使用不同的解决方案,例如nginx创建自己的 pid 文件。

于 2012-12-28T03:15:02.337 回答