Start-stop-daemon does not write the nginx.pid file, even if the file is present

This may be a recurring question, but it is not. I found several articles where start-stop-daemon does not create a PID file. But in my case, I already created the PID file. I run 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 start-stop-daemon not written to the file. I even tried using the --make-pidfile , but then start-stop-daemon writes the wrong pid to the file.

+6
source share
1 answer

The --make-pidfile option is required. The reason start-stop-daemon writes the "wrong pid" is because nginx forks. This is noted on the start-stop-daemon man page:

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

(see the section "Re-flashing a part".)

You will need to use another solution, for example, get nginx to create your own pid file.

+7
source

Source: https://habr.com/ru/post/925564/


All Articles