Monitoring Dockers

I have a fig configuration to run N docker containers (app, redis, mongo, postgre, etc.)

When I run fig up, everything is fine.

      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 important reason, one of these containers can be disabled.

      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 

You can configure supervisord to monitor all containers and start a container that has been disconnected.

+4
source share
2 answers

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

#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

(mongo.conf app.conf) (mongo app).

, .

, , , .

:

sudo supervisorctl 

:

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

!!

+6

Upstart, . Supervisord , .

0

Source: https://habr.com/ru/post/1548089/


All Articles