2012-09-17 8 views
6

Questa potrebbe sembrare una domanda ripetuta ma non lo è. Ho trovato alcuni articoli su di esso in cui start-stop-daemon non crea un file PID. Ma nel mio caso, ho già creato il file PID. Ho eseguito questo comando sul mio server per avviare Nginx:start-stop-daemon non scrive nel file nginx.pid anche se il file è presente

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

lima Il PID è già presente, ma ancora il start-stop-daemon non scrive al file. Ho anche provato a usare l'opzione --make-pidfile ma poi lo start-stop-daemon scrive pid errato sul file.

risposta

7

L'opzione --make-pidfile è obbligatoria. Il motivo start-stop-daemon scrive il "pid errato" è quello forche nginx. Questo si nota nella pagina start-stop-daemon man:

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

(vedere la parte ri biforcano.)

avrete bisogno di utilizzare una soluzione diversa, come ad esempio ottenendo nginx per creare un proprio file pid.

+0

ottenere 'nginx'per creare il proprio file: questo è descritto qui: http://wiki.nginx.org/CoreModule#pid. Fondamentalmente devi solo aggiungere la direttiva pid al tuo file nginx.conf. – Such