2017-02-09 3 views
0

NGINXsupervisordで停止しようとするとエラーが発生しました。プロセスを停止するsupervisorctlを使用した場合Supervisord - NGINX stop OSError

$ supervisord -n 
2017-02-09 12:26:06,371 INFO RPC interface 'supervisor' initialized 
2017-02-09 12:26:06,372 INFO RPC interface 'supervisor' initialized 
2017-02-09 12:26:06,372 CRIT Server 'unix_http_server' running without any HTTP authentication checking 
2017-02-09 12:26:06,373 INFO supervisord started with pid 22152 
2017-02-09 12:26:07,379 INFO spawned: 'nginx' with pid 22155 
2017-02-09 12:26:08,384 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) 

^C# SIGINT: Should stop all processes 

2017-02-09 13:59:08,550 WARN received SIGINT indicating exit request 
2017-02-09 13:59:08,551 CRIT unknown problem killing nginx (22155):Traceback (most recent call last): 
    File "/Users/ocervell/.virtualenvs/ndc-v3.3/lib/python2.7/site-packages/supervisor/process.py", line 432, in kill 
    options.kill(pid, sig) 
    File "/Users/ocervell/.virtualenvs/ndc-v3.3/lib/python2.7/site-packages/supervisor/options.py", line 1239, in kill 
    os.kill(pid, signal) 
OSError: [Errno 1] Operation not permitted 

同じ:私はこれを実行すると

[supervisord] 
[program:nginx] 
command=sudo nginx -c %(ENV_PWD)s/configs/nginx.conf 

:私はsupervisord.confでnginxのコマンドにsudoを付加しなければならなかったsupervisordからエラーなしNGINXを開始するには

$ supervisorctl stop nginx 
FAILED: unknown problem killing nginx (22321):Traceback (most recent call last): 
    File "/Users/ocervell/.virtualenvs/ndc-v3.3/lib/python2.7/site-packages/supervisor/process.py", line 432, in kill 
    options.kill(pid, sig) 
    File "/Users/ocervell/.virtualenvs/ndc-v3.3/lib/python2.7/site-packages/supervisor/options.py", line 1239, in kill 
    os.kill(pid, signal) 
OSError: [Errno 1] Operation not permitted 

これには回避策がありますか?

+0

質問は、なぜnginxを監督で始めたいのですか?これはデーモン化します。つまり、デーモンが終了し、スーパーバイザーがそれを障害として検出します(そうではありません)。それは低いポート番号(80と443)にバインドするので、sudoで実行する必要があります。そのデーモンを監督する決定をし直してください。スーパーバイザがその仕事をすることができるようにnginxを実行させるには、daemonizeしないように指示する必要があります。 [こちらをnginx docsから参照してください](http://nginx.org/en/docs/faq/daemon_master_process_off.html)。 –

+0

nginxを起動すると、nginx configに 'daemon off'が表示されます。問題はスーパーバイザでどのようにそれを殺すかです。私がスーパーバイザーとnginxを開始/停止したい理由は、実行中のすべてのプロセス(webservers、redis、rabbitmqなど)にnginxを含むオン/オフスイッチが必要なことです。 –

+0

ここでは暗闇の中で刺すようにしようとしています - 'sudo supervisorctl stop nginx'、まだ試しましたか? –

答えて

0

supervisordによって作成されたプロセスが独自の子プロセスを作成した場合、supervisordはそれらを強制終了できません。スーパーバイザーがインストールされている場合

...

はpidproxyプログラムは、(それが「コンソールスクリプト」である)、コンフィギュレーションの$ BINDIRに入れています。 [1]

それでは、あなたがしなければならないことは、このようなあなたのsupervisord構成を変更されています

[program:nginx] 
command=/path/to/pidproxy /path/to/nginx-pidfile sudo nginx -c %(ENV_PWD)s/configs/nginx.conf 

nginxのプロセスがsudoによって作成されるので、これは、いずれかの動作しない場合があります。しかしまずそれを試してみましょう。

+0

私の端末で' pidproxy /tmp/nginx.pid sudo nginx -c \ 'pwd \'/configs/nginx.conf'を実行しようとしましたが、実行中のnginxプロセスを参照してください。 –