Using Supervisord for self-booting of Docker container

Source: Internet
Author: User
Tags ini zookeeper
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.