Docker 中的 Supervisor 不起作用

Mil*_*nic 3 supervisord docker

我有一个supervisor问题docker。我使用supervisor来启动 4 个脚本.shdatagrid.shml.shstartmap.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
Run Code Online (Sandbox Code Playgroud)

我的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
Run Code Online (Sandbox Code Playgroud)

我在容器中使用alpine linux。

小智 8

这里有几个问题

  1. 以下声明:

    [supervisord] nodaemon=false

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

尝试将其更改为

[supervisord]
nodaemon=true
Run Code Online (Sandbox Code Playgroud)

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

  1. 从日志“520 INFO 退出:datagrid(退出状态 0;不是预期的)”

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

[program:datagrid]
command=sh /EscomledML/MLScripts/escomled_data_grid.sh start -D
autorestart=unexpected
exitcodes=0
Run Code Online (Sandbox Code Playgroud)