Docker中的Supervisor无法工作

3

我在docker中使用supervisor启动 4 个.sh脚本:datagrid.shml.shstartmap.shdirwatcher.sh。当我打开容器并导航到脚本目录,尝试手动启动脚本时,一切都正常,所有脚本都可以启动,但它们不会在启动时间自动启动。我认为问题出在supervisor上。谢谢。

错误信息:

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

我在容器中使用阿尔派 Linux 操作系统。


尝试使用https://immortal.run,一些人已经在docker中使用它:https://github.com/immortal/immortal/issues/34#issuecomment-362082580 - nbari
我对Docker还不熟悉,你能给我更多的信息吗? - Milan Panic
1
可能这个可以帮助:https://github.com/nbari/docker/tree/master/immortal 它将保持运行状态,这个是 https://github.com/nbari/docker/blob/master/immortal/sleep.yml - nbari
嗨,只需克隆repo https://github.com/nbari/docker/tree/master/immortal,并在目录中执行`docker build -t test-immortal,然后执行docker run -it --privileged test-immortal .` - nbari
我已经这样做了,但它显示“start.sh没有这个文件或目录”。 - Milan Panic
显示剩余2条评论
1个回答

7
这里有一些问题。
以下语句:
[supervisord] nodaemon=false 会让Supervisord作为守护进程运行,容器需要一个主进程。
尝试将其更改为:
[supervisord]
nodaemon=true

这个配置使得Supervisord本身作为前台进程运行,可以让容器保持运行状态。

  1. 从日志中看到 '520 INFO exited: datagrid (exit status 0; not expected)'

Supervisord无法识别0作为有效的退出代码并终止了进程。对于所有的进程,在其配置文件中添加以下内容。这将告诉Supervisord只有当退出码不是0时才尝试重新启动该进程。

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

我一直在寻找类似问题的解决方案,这个方法非常有效! - lordg
为什么我们不能有2个主进程?我们需要在Docker上下文之外进行配置吗?如果我们正在使用apache,为什么supervisor也会停止apache? - famas23

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接