加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 运营中心 > Nginx > 正文

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

发布时间:2020-12-13 21:29:59 所属栏目:Nginx 来源:网络整理
导读:这似乎是一个重复的问题,但事实并非如此.我在其上发现了一些文章,其中start-stop-daemon不会创建PID文件.但就我而言,我已经创建了PID文件.我在服务器上执行此命令以启动Nginx: /mnt/nginx/logs/nginx.pidstart-stop-daemon --start --quiet --pidfile /mnt/

这似乎是一个重复的问题,但事实并非如此.我在其上发现了一些文章,其中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文件.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读