Docker容器内supervisorctl命令无法执行的问题求助
解决Docker容器内supervisorctl命令无法执行的问题
问题分析
- 初始错误
Error: .ini file does not include supervisorctl section:配置文件缺少[supervisorctl]段,导致supervisorctl无法识别连接supervisord的方式 - 添加
serverurl=http://127.0.0.1:9001后报错Errno 99 Cannot assign requested address:你的supervisord仅启用了Unix域套接字(对应配置里的[unix_http_server]),未开启TCP端口的HTTP服务,因此TCP连接请求无法被处理
正确配置与操作步骤
修正
[supervisorctl]配置段
由于supervisord使用Unix套接字通信,supervisorctl必须对应使用该套接字,将配置修改为:[supervisorctl] serverurl=unix:///tmp/supervisor.sock让配置变更生效
修改配置后必须重载或重启supervisord,否则新配置不会生效:- 重载(推荐,不中断运行中的进程):
supervisorctl -c /app/worker.conf reload - 重启(重载无效时使用,会终止所有受管理进程):
# 停止supervisord supervisorctl -c /app/worker.conf shutdown # 重新启动supervisord supervisord -c /app/worker.conf
- 重载(推荐,不中断运行中的进程):
执行supervisorctl命令
确保指定正确的配置文件(若默认路径不是/app/worker.conf):supervisorctl -c /app/worker.conf status supervisorctl -c /app/worker.conf restart worker
额外注意事项
- Docker容器内运行supervisord时,
nodaemon=true配置正确,确保supervisord在前台运行(符合Docker容器的运行要求) - 若出现套接字权限错误,可在
[unix_http_server]段添加chmod=0766调整权限,保证运行supervisorctl的用户有读写权限
内容的提问来源于stack exchange,提问作者SRJ
相关产品推荐
相关产品推荐

