首页 > 解决方案 > Docker 中的主管不起作用

问题描述

supervisor我对in有问题docker。我使用supervisor来启动 4 个脚本.shdatagrid.shml.sh和.startmap.shdirwatcher.sh

当我打开容器时,导航到脚本目录并尝试手动启动脚本,一切正常,脚本全部启动,但它们不会在启动时间启动。我认为问题出在主管身上。谢谢你。

错误:

2018-08-08 12:28:08,512 INFO spawned: 'datagrid' with pid 171
2018-08-08 12:28:08,514 INFO spawned: 'dirwatcher' with pid 172 
2018-08-08 12:28:08,517 INFO spawned: 'startmap' with pid 173 
2018-08-08 12:28:08,519 INFO spawned: 'ml' with pid 175 
2018-08-08 12:28:08,520 INFO exited: datagrid (exit status 0; not expected)
2018-08-08 12:28:08,520 INFO exited: dirwatcher (exit status 0; not expected)
2018-08-08 12:28:08,520 INFO exited: startmap (exit status 0; not expected)
2018-08-08 12:28:08,520 INFO exited: ml (exit status 0; not expected)
2018-08-08 12:28:08,527 INFO gave up: datagrid entered FATAL state, too many start retries too quickly
2018-08-08 12:28:08,532 INFO gave up: ml entered FATAL state, too many start retries too quickly
2018-08-08 12:28:08,537 INFO gave up: startmap entered FATAL state, too many start retries too quickly
2018-08-08 12:28:08,539 INFO gave up: dirwatcher entered FATAL state, too many start retries too quickly

我的supervisord.conf文件:

[supervisord]
nodaemon=false

[program:datagrid]
command=sh /EscomledML/MLScripts/escomled_data_grid.sh start -D

[program:dirwatcher]
command=sh /EscomledML/MLScripts/escomled_dirwatcher.sh start -D

[program:startmap]
command=sh /EscomledML/MLScripts/escomled_startmap.sh start -D

[program:ml]
command=sh /EscomledML/MLScripts/escomled_ml.sh start -D

我在容器中使用 alpine linux。

标签: dockersupervisord

解决方案


这里的问题很少

  1. 以下声明:

    [主管] nodaemon=false

这使得 Supervisord 作为守护进程运行,并且容器需要一个主进程。

尝试将其更改为

[supervisord]
nodaemon=true

此配置使 Supervisord 本身作为前台进程运行,这将使容器保持正常运行。

  1. 从日志“520 INFO 退出:数据网格(退出状态 0;不期望)”

Supervisord 无法将 0 识别为有效的退出代码并正在退出进程。将以下内容添加到所有进程的 conf 中。这将告诉 Supervisord 仅在退出代码不为 0 时尝试重新启动进程

[program:datagrid]
command=sh /EscomledML/MLScripts/escomled_data_grid.sh start -D
autorestart=unexpected
exitcodes=0

推荐阅读