即使文件存在,start-stop-daemon也不会写入nginx.pid文件

前端之家收集整理的这篇文章主要介绍了即使文件存在,start-stop-daemon也不会写入nginx.pid文件前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

这似乎是一个重复的问题,但事实并非如此.我在其上发现了一些文章,其中start-stop-daemon不会创建PID文件.但就我而言,我已经创建了PID文件.我在服务器上执行此命令以启动Nginx

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

PID文件已存在但仍然是start-stop-daemon不写入文件.我甚至尝试使用–make-pidfile选项,但是start-stop-daemon将错误的pid写入文件.

最佳答案
–make-pidfile选项是必需的. start-stop-daemon写“错误的pid”的原因是Nginx forks.这在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文件.

猜你在找的Nginx相关文章