2012-09-17 26 views
6

這似乎是一個重複問題,但事實並非如此。我發現了一些文章,其中start-stop-daemon沒有創建PID文件。但就我而言,我已經創建了PID文件。我在我的服務器上執行此命令來啓動Nginx的:即使文件存在,start-stop-daemon也不會寫入nginx.pid文件

/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寫入該文件。

回答

7

--make-pidfile選項是必需的。 start-stop-daemon寫道「錯誤的pid」的原因是nginx叉。這是在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文件。

+0

讓'nginx'創建自己的文件:這裏描述:http://wiki.nginx.org/CoreModule#pid。基本上你只需要將pid指令添加到你的nginx.conf文件中。 – Such

相關問題