2012-09-17 3 views
6

これは繰り返し質問のようですが、そうではありません。 start-stop-daemonがPIDファイルを作成していない記事を見つけました。しかし私の場合、私はすでにPIDファイルを作成しています。ファイルが存在しても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はファイルに書き込めません:私はnginxのを開始するために私のサーバー上でこのコマンドを実行します。私も--make-pidfileオプションを使用しようとしましたが、start-stop-daemonは間違ったpidをファイルに書き出します。

答えて

7

--make-pidfileオプションが必要です。理由は、start-stop-daemonは "間違ったpid"と書いているのはnginxです。これは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. 

が(フォーク再部分を参照してください。)

あなたは、このような独自のPIDファイルを作成するために、nginxを得るよう、別のソリューションを使用する必要があります。

+0

'nginx'を使って独自のファイルを作成します:これはhttp://wiki.nginx.org/CoreModule#pidです。基本的には、nginx.confファイルにpidディレクティブを追加するだけです。 – Such

関連する問題