Daemontools Installation and use
Reference:
Http://cr.yp.to/daemontools/install.html
The daemontools is used to automatically restart the process. When a critical service process crashes, you can start it with Daemontools. The premise is to install and configure it. For example, the Zookeeper service, as a critical service, must be restarted after a crash. The installation and usage of Daemontools on RHEL6.4 (EL6) is described below.
1 Installing Daemontools
The first is el6 to install GCC:
# yum Install gcc
Then download and install the Daemontools:
# wget--no-check-certificate http://cr.yp.to/daemontools/daemontools-0.76.tar.gz# tar zxf daemontools-0.76.tar.gz# CD admin/daemontools-0.76/# sed-i ' s/extern int errno;/#include <errno.h>/1 './src/error.h#./package/install
2 Using Daemontools
Configure the startup item to add CSH-CF '/command/svscanboot & ' to the end of /etc/rc.local :
# sed '/$/acsh-cf \x27\/command\/svscanboot &\x27 '/etc/rc.local# source/etc/rc.local
Supervise monitors a directory (such as test), the test directory has an executable script run, and if the run script exits, supervise rerun it. So we write the logic of the startup service in the run script, for example, I monitor the operation of the Salt-minion service, and can write the following run script:
#!/bin/bashservice salt-minion startwhile truedo ret= ' service salt-minion status|grep ' stopped ' if [-Z ' $ret ' ]; Then Echo ' service was running ' sleep ' else echo ' service is stopped ' break Fidone
This script starts the Salt-minion service first, then determines whether the service is normal, and exits the break if it is not normal. Normally the loop is detected (the run script does not exit).
Then execute the following command to let supervise monitor it:
# supervise./test# svc-u./test
Daemontools Installation and use