First, installation configuration supervisor
1. Installing the Python automation tool #yum install Python-setuptools
2. #easy_install Supervisor Installation Supervisor
3. Test whether the installation was successful #echo_supervisord_conf
4. Create the configuration file:
(1) Create Supervisor profile Directory/etc/supervisor/
#mkdir-M 755-p/etc/supervisor/
(2) Create a master file supervisord.conf
#echo_supervisord_conf >/etc/supervisor/supervisord.conf
(3) Create a project configuration file directory
# mkdir-m 755 CONF.D
5. Add a test profile to the profile directory
such as: Convert.ini
And then add it at the bottom of the main profile supervisord.conf
[include]
File =./conf.d/convert.ini
6. Start Supervisor---manual start
# supervisord-c/etc/supervisor/supervisord.conf
Pstree-p | grep Supervisord
View Supervisord.log Discovery Program Convert started
# Cat/tmp/supervisord.log
7. #supervisorctl-C/etc/supervisor/supervisord.conf into the supervisor management
Status View state
Stop all Stop
Reload Restart monitoring Service
Attention:
(1) Each time you modify the configuration file , you need to enter Supervisorctl, execute reload, change the part to take effect
(2) Two commands
Supervisord:supervisor server-side section for supervisor startup
Supervisorctl: Launches the command-line window for supervisor, which performs actions such as Start, stop, status, reload, and so on in the command line.
Second, Supervisord startup script
1. Execute the following command:
Vim/etc/init.d/supervisord
2. Enter the following:
#!/bin/bash## Supervisord This scripts turns supervisord on# chkconfig:345 04# description:supervisor is a process Control Utility. It has a Web based# XMLRPC interface as well as a few other nifty features.## source function library. /etc/rc.d/init.d/functionsset-aprefix=/usrsupervisord= $PREFIX/bin/supervisordsupervisorctl= $PREFIX/bin/ Supervisorctlpidfile=/var/supervisor/supervisord.pidlockfile=/var/supervisor/supervisord.lockoptions= "-c/etc/ supervisor/supervisord.conf "# unset this variable if you don ' t care to wait for the child processes to shutdown before Removin G The $LOCKFILE-lockwait_for_subprocesses=yes# remove this if you manage number of open files in some other fashionulimit -N 96000retval=0running_pid () {# Check If a given process PID ' s cmdline matches a given name pid=$1 name=$2 [-z] $pid "] && return 1 [! -d/proc/$pid] && return 1 (cat/proc/$pid/cmdline | tr "\000" "\ n" |grep-q $name) | | Return 1 return 0}running () {# Check if the ProcesS is running looking at/proc# (works for all users) # no pidfile, probably No daemon present [!-F "$PIDFILE"] && Amp Return 1 # Obtain the PID and check it against the binary name pid= ' cat $PIDFILE ' running_pid $pid $SUPERVISORD | | Return 1 return 0}start () {echo "Starting Supervisord:" If [-e $PIDFILE]; Then echo ' already STARTED ' return 1 fi # start Supervisord with options from sysconfig (stuff like-c) $SUPER Visord $OPTIONS # Show initial startup status $SUPERVISORCTL $OPTIONS status # Only create the Subsyslock if we created The Pidfile [-e $PIDFILE] && touch $LOCKFILE}stop () {echo-n "stopping Supervisord:" $SUPERVISORCTL $OPTIONS shutdown if [-N ' $WAIT _for_subprocesses "]; Then echo "waiting roughly-seconds for $PIDFILE-be-removed after-child processes exit ' for sleep in 2 2 2 2 4 4 4 4 8 8 8 8 last; do if [!-e $PIDFILE]; Then Echo ' Supervisord exited as expected in under $total _sLeep seconds "Break else if [[$sleep-eq" last "]]; Then echo ' Supervisord still working on shutting down. We ' ve waited roughly seconds, we'll let it does its thing from here "return 1 else sleep $ Sleep total_sleep=$ (($total _sleep + $sleep)) fi fi do fi # always remove the Sub Sys. We might has waited a while, but just remove the it at this point. Rm-f $LOCKFILE}restart () {Stop start}case "$" in start) Start retval=$? ;; Stop) Stop retval=$? ;; restart|force-reload) Restart retval=$? ;; Reload) $SUPERVISORCTL $OPTIONS reload retval=$? ;; Condrestart) [-F $LOCKFILE] && restart retval=$? ;; Status) $SUPERVISORCTL $OPTIONS status if running; Then retval=0 else retval=1 fi;; *) echo $ "Usage: $ Start|stop|status|restart|reload|force-reload|condrestart}" Exit 1esacexit $RETVAL
Note: the following variables in the file need to be rewritten according to your actual directory.
prefix=/usrsupervisord= $PREFIX/bin/supervisord # #supervisord program installation path supervisorctl= $PREFIX/bin/ Supervisorctl # #supervisorctl Program installation path Pidfile=/var/supervisor/supervisord.pid # #需要先创建/var/ Supervisor Directory Lockfile=/var/supervisor/supervisord.lockoptions= "-c/etc/supervisor/supervisord.conf" # # Path to the configuration file
After saving, you can modify the file permissions by executing the following command:
chmod 777/etc/init.d/supervisord/etc/init.d/supervisord Start or service Supervisord start
So supervisor started it.
3. Configure Boot Boot
Execute the following command:
Chkconfig Supervisord on
You can see whether the following command is successful
Chkconfig--list | grep Supervisord
Supervisor CentOS Installation