supervisor boot script + redis+MySQL+tomcat+nginx process automatic restart configuration

Keywords: MySQL Redis Nginx supervisor

supervisor boot-up automatic restart script

#! /bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
PROGNAME=supervisord
DAEMON=/usr/bin/$PROGNAME
CONFIG=/etc/$PROGNAME.conf
PIDFILE=/tmp/$PROGNAME.pid
DESC="supervisord daemon"
SCRIPTNAME=/etc/init.d/$PROGNAME

# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0

start()
{
        echo -n "Starting $DESC: $PROGNAME"
        $DAEMON -c $CONFIG
        echo "..."
}

stop()
{
        echo -n "Stopping $DESC: $PROGNAME"
        supervisor_pid=$(cat $PIDFILE)
        kill -15 $supervisor_pid
        echo "..."
}

status()
{
        ps -ef|grep supervisord
}

case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  status)
        status
        ;;
  restart)
        stop
        start
        ;;
  *)
        echo "Usage: $SCRIPTNAME {start|stop|restart|status}" >&2
        exit 1
        ;;
esac
exit 0

Then you need to configure the startup command in the boot system file (the following command is to write to it, or you can add it manually by yourself)

[root@JD ~]# echo "/etc/inin.d/supervisord start" > /etc/rc.d/rc.sysinit 

supervisor project management process configuration files (are some basic configuration, are able to manage the process, to better configure you can go to the Internet to find, just write in the file)

It should be noted that all processes to be managed can not open the background mode, but can only be configured using the foreground mode; using the background mode will always reopen the new process.

mysql configuration file (note the command, here is to execute this command to start the process, you can find your own process start command)

[program:mysql]
command=/usr/local/tools/mysql/bin/mysqld --basedir=/usr/local/tools/mysql --datadir=/usr/local/tools/data/mysql --plugin-dir=/usr/local/tools/mysql/lib/plugin --user=mysql  --log-error=/var/log/mysqld.log --pid-file=/usr/local/tools/data/mysql/JD.jcloud.local.pid --socket=/usr/local/tools/data/mysql/mysql.sock
process_name=%(program_name)s
priority=1001
autostart=true
startretries=3
autorestart=true
user=root
Redis configuration file (close the background mode of redis, that is, modify the daemon in redis.conf to no)

[program:redisd]
command=/usr/local/redis/bin/redis-server
process_name=%(program_name)s
priority=1001
autostart=true
startretries=3
autorestart=true
user=root

nginx configuration file (also to turn off background mode, add-g "daemon off;" after executing commands)
[program:nginx]
command=/usr/local/tools/nginx/sbin/nginx -g 'daemon off;'
process_name=%(program_name)s
priority=1000
autostart=true
startretries=3
autorestart=true
user=root

tomcat configuration file (same as closing background mode, using catalina.sh run)

[program:tomcat1]
command=/usr/local/tools/tomcat1/bin/catalina.sh run
process_name=%(program_name)s
environment=JAVA_HOME="/usr/local/tools/jdk1.7.0_71/",JAVA_BIN="/usr/local/tools/jdk1.7.0_71/bin"
priority=1000
autostart=true
startretries=3
autorestart=true
user=root
~          

Posted by clairian on Wed, 06 Feb 2019 20:27:17 -0800