CentOS7 Installation Supervisor
# install
sudo yum install python-setuptools-y
sudo easy_install supervisor
# generate default Config file
sudo sh-c ' echo_super visord_conf >/etc/supervisord.conf '
# Create a startup script
sudo vim/etc/rc.d/init.d/supervisord
Here is the init script
#!/bin/bash. /etc/init.d/functions Daemon=/usr/bin/supervisord Pidfile=/var/run/supervisord.pid [-X "$DAEMON"] | | Exit 0 start () {echo-n "Starting Supervisord:" If [-f $PIDFILE];
Then pid= ' Cat $PIDFILE ' echo Supervisord already running: $PID exit 2;
else Daemon $DAEMON--pidfile= $PIDFILE-c/etc/supervisord.conf retval=$? echo [$RETVAL-eq 0] && Touch/var/lock/subsys/supervisord return $RETVA L fi} Stop () {echo-n "shutting down Supervisord:" Echo killproc-p $PIDFILE Supervis
Ord Echo rm-f/var/lock/subsys/supervisord return 0} case "$" in start) start
;;
stop) stop;;
status) status Supervisord;;
restart) stop start;; *) echo "Usage: {start|stop|stAtus|restart} "exit 1;; ESAC exit $?
Don't forget to empower the script.
sudo chmod +x/etc/rc.d/init.d/supervisord
Configure Supervisor
Create a new standalone configuration file, such as/media/storage/work/supervisord.ini, to configure the startup of each container
Docker start-a means attaching to an existing container, or starting a new container (if not started)
[Program:zookeeper]
Command=/usr/bin/docker start-a Zookeeper
[Program:env3_mysql_log]
command=/usr/bin/docker start-a env3_ Mysql_log
[Program:stage_mysql_log]
command=/usr/bin/docker start-a stage_mysql_log
[Program:stage_ Redis]
command=/usr/bin/docker start-a stage_redis
[program:webapi-1]
command=/usr/bin/docker Start- A webapi-1
[program:webapi-2]
command=/usr/bin/docker start-a webapi-2
[program:webapi-3]
Command=/usr/bin/docker start-a webapi-3
This configuration file is then introduced in the/etc/supervisord.conf configuration
[include]
Files =/media/storage/work/supervisord.ini
Finally start the Supervisord service
sudo service Supervisord restart