web environment
ngnix、php-fpm
Monitoring ideas
Use linux scheduled task to run every minute monitoring script that uses wget detection program is working, and then start later if the program is abnormal, get ngnix main process ID, kill off the process; get php-fpm main process ID, and then start after kill off process
Monitoring Script
Create a file monitor.sh
1 #!/bin/sh 2 wget --spider -t 1 -T 2 http://127.0.0.1:53727 -q 3 if [ $? -ne 0 ] 4 then 5 ngnixpid=`ps aux|grep 'nginx: master'|grep -v grep|awk '{print $1}'` 6 if [ -n "$ngnixpid" ] 7 then 8 kill -INT $ngnixpid 9 fi 10 /ngnix/ngnix & 11 phppid=`ps aux|grep 'php-fpm: master'|grep -v grep|awk '{print $1}'` 12 if [ -n "$phppid" ] 13 then 14 kill -INT $phppid 15 fi 16 /usr/sbin/php-fpm -R & 17 fi
Create a scheduled task
Timing task execution file webmonitor
* * * * * /etc/monitor.sh &> /dev/null
Create a scheduled task when the device starts
ln -s /bin/busybox /bin/crontab ln -s /bin/busybox /bin/crond mkdir -p /var/spool/cron/crontabs crontab /etc/webmonitor /bin/crond -l 9
Because I'm using embedded devices, so regular tasks using a busybox in the crontab, if a general server, you can set up according to the situation.