最新消息:20210917 已从crifan.com换到crifan.org

【已解决】Mac中运行supervisord再运行supervisorctl出错:http://localhost:9001 refused connection

Mac crifan 1014浏览 0评论
折腾:
【已解决】Mac本地用supervisor和gunicorn启动和管理Flask的app
期间,Mac中运行supervisorctl status出错:
➜  xxxRobotDemoServer git:(master) ✗ supervisord -c conf/supervisor/supervisord_local.conf
➜  xxxRobotDemoServer git:(master) ✗ supervisorctl status
http://localhost:9001
 refused connection
9001拒绝连接。
然后搜了下,现在的
conf/supervisor/supervisord_local.conf
中有9001的值,但是都是注释掉的:
[supervisorctl]
;serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL  for a unix socket
serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL  for a unix socket
;serverurl=
http://127.0.0.1:9001
 ; use an http:// url to specify an inet socket

;[inet_http_server]         ; inet (TCP) server disabled by default
;port=127.0.0.1:9001        ; ip_address:port specifier, *:port for all iface
mac supervisord http://localhost:9001 refused connection
mac supervisor http://localhost:9001 refused connection
supervisor安装的之后9001端口连不上 – 开源中国社区
16.04 – supervisorctl 3.3.1 http://localhost:9001 refused connection – Ask Ubuntu
https://askubuntu.com/questions/911994/supervisorctl-3-3-1-http-localhost9001-refused-connection
去开启inet_http_server试试
[inet_http_server]         ; inet (TCP) server disabled by default
port=127.0.0.1:9001        ; ip_address:port specifier, *:port for all iface
需要重新加载配置
但是又没法使用supervisorctl
然后试了试:
➜  xxxRobotDemoServer git:(master) ✗ supervisord -c conf/supervisor/supervisord_local.conf
Error: Another program is already listening on a port that one of our HTTP servers is configured to use.  Shut this program down first before starting supervisord.
For help, use /Users/crifan/Library/Python/2.7/bin/supervisord -h
看来只能强制干掉对应进程了?
➜  xxxRobotDemoServer git:(master) ✗ ps aux | grep supervisor
crifan           54179   0.1  0.1  4310560   7528   ??  Ss    2:24PM   0:02.93 /usr/bin/python /Users/crifan/Library/Python/2.7/bin/supervisord -c conf/supervisor/supervisord_local.conf
crifan           54745   0.0  0.0  4267752    736 s007  R+    2:34PM   0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn supervisor
➜  xxxRobotDemoServer git:(master) ✗ kill -9 54179
➜  xxxRobotDemoServer git:(master) ✗ ps aux | grep supervisor
crifan           54788   0.0  0.0  4267752    648 s007  R+    2:34PM   0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn supervisor
然后再去启动,果然可以了:
➜  xxxRobotDemoServer git:(master) ✗ supervisord -c conf/supervisor/supervisord_local.conf
Unlinking stale socket /var/run/supervisor.sock
➜  xxxRobotDemoServer git:(master) ✗ supervisorctl status                                 
robotDemo                        RUNNING   pid 54817, uptime 0:00:00
【总结】
Mac本地用supervisord启动gunicorn的Flask的app时,之前配置没有开启inet_http_server:
conf/supervisor/supervisord_local.conf
;[inet_http_server]         ; inet (TCP) server disabled by default
;port=127.0.0.1:9001        ; ip_address:port specifier, *:port for all iface
所以启动:
supervisord -c conf/supervisor/supervisord_local.conf
后,去用supervisorctl status连不上, 出现:
➜  xxxRobotDemoServer git:(master) ✗ supervisorctl status
http://localhost:9001
 refused connection
而supervisord在3.0+中:
已经规定了:
A TCP host:port value or (e.g. 127.0.0.1:9001) on which supervisor will listen for HTTP/XML-RPC requests. supervisorctl will use XML-RPC to communicate with supervisord over this port. To listen on all interfaces in the machine, use :9001 or *:9001.
Default: No default.
Required: Yes.
Introduced: 3.0
所以需要去开启:
[inet_http_server]         ; inet (TCP) server disabled by default
port=127.0.0.1:9001        ; ip_address:port specifier, *:port for all iface
然后重启supervisord即可。
注:
正常情况下,可以通过
supervisorctl reload
去重新加载配置的,但是此处由于无效,所以是通过
px aux| grep supervisor
找到进程号54179,然后:
kill -9 
54179
强制杀掉supervisord
然后重启运行即可:
➜  xxxRobotDemoServer git:(master) ✗ supervisord -c conf/supervisor/supervisord_local.conf
Unlinking stale socket /var/run/supervisor.sock
➜  xxxRobotDemoServer git:(master) ✗ supervisorctl status                                 
robotDemo                        RUNNING   pid 54817, uptime 0:00:00

转载请注明:在路上 » 【已解决】Mac中运行supervisord再运行supervisorctl出错:http://localhost:9001 refused connection

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
95 queries in 0.162 seconds, using 23.43MB memory