无花果码头监测破碎的容器 [英] fig docker monitoring broken container

查看:108
本文介绍了无花果码头监测破碎的容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个无线配置,用于启动 N 码头容器(app,redis,mongo,postgre等)。



我运行 fig up 一切都可以。

 命名状态端口
----------------------------------------------- ---------------------------
my_mongodb_1 / usr / local / bin / run Up 28017 / tcp,27017 / tcp
my_redis_1 / usr / local / bin / run Up 6379 / tcp
my_pg_1 / usr / local / bin / run Up 5432 / tcp
my_app_1 ... Up 443-> 443 / tcp,80 - > 80 / tcp

但是一个不重要的原因之一可以关闭这个容器之一。

 名称命令状态端口
------------------ -------------------------------------------------- ------
my_mongodb_1 / usr / l ocal / bin / run up 28017 / tcp,27017 / tcp
my_redis_1 / usr / local / bin / run退出6379 / tcp
my_pg_1 / usr / local / bin / run Up 5432 / tcp
my_app_1 ... Up 443-> 443 / tcp,80-> 80 / tcp

可以配置 supervisord 来监视所有容器并启动已关闭的容器

解决方案

您必须将不同文件中的每个程序(容器)配置为必须位于 /etc/supervisor/conf.d/ 文件夹中,其中主管应查找程序。在你的情况下,我建议:

 #这是/redis.conf 
[程序:redis]
命令= / bin / bash -cfig up redis
fig logs redis
directory = / path / of / fig_file
autostart = true
autorestart = true
stdout_logfile = / path / to / log / redis.log
redirect_stderr = true

对于pg:

 #这是/pg.conf 
[程序:pg]
命令= / bin / bash -cfig up pg
fig logs pg
directory = / path / of / fig_file
autostart = true
autorestart = true
stdout_logfile = / path / to / log / pg.log
redirect_stderr = true

和其他程序(mongo和app)相同的配置(mongo.conf和app.conf)。



当您启动机器或重新启动它时,每个程序必须起来



上面的示例运行容器,您可以保留它,因为您可以保留它的日志。



您可以通过以下方式检查每个程序的状态:

  sudo supervisorctl 
pre>

请参阅:

 应用程序运行pid 17036,正常运行时间0 :22:28 
mongodb运行pid 17018,正常运行时间0:22:29
pg运行pid 17030,正常运行时间0:22:28
redis RUNNING pid 17019,正常运行时间0:22:29

祝你好运!!


I have a fig configuration for launch N dockers containers (app, redis, mongo, postgre, etc...)

When I run fig up everything is ok.

      Name      Command               State            Ports           
--------------------------------------------------------------------------
my_mongodb_1   /usr/local/bin/run       Up      28017/tcp, 27017/tcp     
my_redis_1     /usr/local/bin/run       Up      6379/tcp                 
my_pg_1        /usr/local/bin/run       Up      5432/tcp                 
my_app_1       ...                      Up      443->443/tcp, 80->80/tcp 

but for one not important reason one of this containers could be turned off.

      Name      Command               State            Ports           
--------------------------------------------------------------------------
my_mongodb_1   /usr/local/bin/run       Up      28017/tcp, 27017/tcp     
my_redis_1     /usr/local/bin/run       Exit    6379/tcp                 
my_pg_1        /usr/local/bin/run       Up      5432/tcp                 
my_app_1       ...                      Up      443->443/tcp, 80->80/tcp 

Is possible to configurate supervisord for monitoring all containers and start the container which has been turned off

解决方案

You have to configure each program (container) in different files and them must be into /etc/supervisor/conf.d/ folder, in where the supervisor should look for the programs. In your case I propose:

#It is the /redis.conf
[program:redis]
command= /bin/bash -c "fig up redis"
        "fig logs redis"
directory=/path/of/fig_file
autostart=true
autorestart=true
stdout_logfile=/path/to/log/redis.log
redirect_stderr=true

And for pg:

#It is the /pg.conf
[program:pg]
command= /bin/bash -c "fig up pg"
        "fig logs pg"
directory=/path/of/fig_file
autostart=true
autorestart=true
stdout_logfile=/path/to/log/pg.log
redirect_stderr=true

And the same configuration (mongo.conf and app.conf) for the others program (mongo and app).

When you boot your machine or restart it, each program must be up.

The example above you run the container and you can keep it alive because you fallow the logs of it.

You can check the state of each programs with:

sudo supervisorctl 

And see:

app                          RUNNING    pid 17036, uptime 0:22:28
mongodb                      RUNNING    pid 17018, uptime 0:22:29
pg                           RUNNING    pid 17030, uptime 0:22:28
redis                        RUNNING    pid 17019, uptime 0:22:29

good luck!!

这篇关于无花果码头监测破碎的容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆