<>Supervisor What is it?
yes Linux/Unix A process management tool under the system , It can be very convenient to monitor , start-up , stop it , Restart one or more processes . use Supervisor Managed processes , When a process is accidentally killed ,supervisort After listening to the death of the process , Will automatically pull it up again , It is very convenient to achieve the function of automatic process recovery , You don't have to write it yourself anymore shell Script to control ,
<> Application scenario
* Perform time-consuming crawler tasks
* Guard queue , as well as workman process
* Procedures that need to be executed all the time
<> install Supervisor
linux Direct execution under yun install , Convenient and fast
yum install -y epel-release && yum install -y supervisor
Three executors will be generated after installation
supervisortd,supervisorctl,echo_supervisord_conf
* supervisortd: For management supervisor Own service
* supervisorctl: For management, we need to delegate to superviso Tool services
* echo_supervisord_conf: Used to generate superviso Configuration file for
* supervisor Daemon service for ( Used to receive process management commands ) [root@ad581v8efzsd5 /]# which supervisord
/bin/supervisord [root@ad581v8efzsd5 /]# which supervisorctl /bin/supervisorctl
[root@ad581v8efzsd5 /]# which echo_supervisord_conf /bin/echo_supervisord_conf
Start after installation
#supervisord start-up supervisord -c /etc/supervisord.conf # start-up supervisord process
<> to write workman cover superviso guard
* Configuration file found
/etc/supervisord.conf
* Add the following code at the bottom vim /etc/supervisord.d/redis.conf [program:dd_thinkphp_workman]
command= /usr/local/php/bin/php think worker:server ; Monitored process directory=
/data/wwwroot/thinkphp6; Project address ( Required ) ;process_name=%(process_num)02d ;numprocs=1
# Start several processes autostart=true ; along with supervisord Start by starting autorestart=true ; Auto start startsecs=1
; When the program restarts, it stays at runing Seconds of status startretries=10 ; Maximum number of retries when startup fails redirect_stderr=true
; redirect stderr reach stdout stdout_logfile= /data/wwwlogs/dd_thinkphp_workman.log;
stdout file , log file
* use super start-up workman # Kill supervisord ps -ef|grep supervisord root 23164 1 0
10:47 ? 00:00:00 /usr/bin/python /bin/supervisord -c /etc/supervisord.conf root
27549 27402 0 11:07 pts/2 00:00:00 grep --color=auto super kill -9 23164
# Restart supervisord Make it reload the configuration file ,supervisord By default workman Pull it up supervisord -c
/etc/supervisord.conf
* Other commands supervisorctl status workman #workman state supervisorctl stopworkman
# stop it workman supervisorctl start workman # start-up workman supervisorctl restart workman
# restart workman supervisorctl reoload workman # heavy load workman
<> Administration supervisorctal
supervisorctl status all # View all process status supervisorctl stop all # Stop all processes
supervisorctl start all # Start all processes supervisorctl restart all # Restart all processes supervisorctl
reoload all # Reload all processes
In general, it is very simple , Like some queues ,workman These can't hang up , Just guard it
Technology
Daily Recommendation