【发布时间】:2017-02-09 20:01:20
【问题描述】:
尝试使用supervisord 停止NGINX 时遇到错误。
要从supervisord 无错误地启动NGINX,我必须在supervisord.conf 的nginx 命令前添加sudo:
[supervisord]
[program:nginx]
command=sudo nginx -c %(ENV_PWD)s/configs/nginx.conf
当我运行这个时:
$ 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
使用supervisorctl 停止进程时相同:
$ 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
有解决办法吗?
【问题讨论】:
-
问题来了,为什么要带监督启动nginx呢?它守护进程,这意味着它退出并且 supervisord 将检测为失败(它不是)。它必须使用 sudo 运行,因为它绑定到低端口号(80 和 443)。重新考虑您监督该守护程序的决定。为了让 nginx 运行以便主管可以完成它的工作,你必须告诉它不要守护进程。 Refer to this, from nginx docs.
-
启动 nginx 工作,我在 nginx 配置中有 'daemon off'。问题是如何用主管杀死它。我想用主管启动/停止 nginx 的原因是我需要为我正在运行的所有进程(webservers、redis、rabbitmq 等)设置一个开/关开关,包括 nginx。
-
只是想在这里暗中刺伤 -
sudo supervisorctl stop nginx,你试过了吗? -
是的,它返回相同的错误
OSError
标签: nginx supervisord