简体   繁体   English

无花果船坞监控破碎的容器

[英]fig docker monitoring broken container

I have a fig configuration for launch N dockers containers (app, redis, mongo, postgre, etc...) 我有一个用于发射N码头工人容器(app,redis,mongo,postgre等等)的无花果配置

When I run fig up everything is ok. 当我运行fig up一切都很好。

      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. 您必须在不同的文件中配置每个程序(容器),并且它们必须/etc/supervisor/conf.d/文件夹中,主管应该在该文件夹中查找程序。 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: 对于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). 和其他程序(mongo和app)的配置相同(mongo.conf和app.conf)。

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!! 祝好运!!

I would use Upstart which I've had pretty good experience from. 我会使用Upstart,我有很好的经验。 Supervisord is best when processes don't daemonize. 当进程没有守护进程时,Supervisord是最好的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM