Brief introduction:
Supervisor Process Management Tools
First, installation
Yum Install python-install3Yum installation also has a problem
Second, the configuration
Shell > Echo_supervisord_conf >/etc/supervisord.conf# generate the configuration file to the specified location, the error when uninstalling the original packaging of this meld3==0.6.7 [Pkg_resources. distributionnotfound:meld3>=0.6.5]shell>grep-vp'^;|^$'/etc/supervisord.conf [Unix_http_server]file=/var/tmp/supervisor.sock. Sock storage location [Supervisord]logfile=/var/log/supervisord.log; log storage location Logfile_maxbytes=50MB; maximum 50mblogfile_backups per log file=Ten; Keep 10 backup loglevel=Info; Log level,Info, Debug,warn,tracepidfile=/var/run/supervisord.pid. PID Storage Position Nodaemon=false; daemon mode start Minfds=1024x768; can open the file descriptor Minprocs= $: Number of processes that can be started [rpcinterface:supervisor]supervisor.rpcinterface_factory=Supervisor.rpcinterface:make_main_rpcinterface[supervisorctl]serverurl=unix:///var/tmp/supervisor.sock; sock storage location# Some default items have been modified slightly
Third, start
Shell > Supervisord-c/etc/supervisord.conf# specifying profile path Shell>PSAux |grepSuproot + 0.0 0.0 0 0? S the: the 0:xx[Sync_supers]root4044 0.0 0.1 199380 11164? Ss -: - 0:xx/usr/bin/python/usr/bin/supervisord-c/etc/supervisord.conf
Iv. Starting a custom script
shell > Vim hello. sh # !/bin/bash for i in {1 .. 10 }; do echo hello; sleep 1 ; done shell > chmod a+x hello.sh
Shell > vim/etc/supervisord.conf[program:hello]directory=/root ; switch to the specified directory command when you run the program=/ Bin/bash Hello. SH ; Execute program (how the program cannot run in the background) Redirect_stderr=true ; standard error output redirected to standard output stdout_logfile= Hello.log ; Specifies the log file path, which can be an absolute path (relative path relative to directory= specified directory) stdout_logfile_maxbytes=50MB ; File Cut size stdout_logfile_backups=ten ; reserved number of backups # Join program startup configuration
Shell >Supervisorctlsupervisor>helpdefault Commands (Type help<topic>):=====================================Add exit Open reload restart startTailavail FG PID remove shutdown status updateClearMaintail quit reread signal the Stop version# Client tool provides some instructions (Supervisorctl help is also possible to run) Supervisor>updatehello:added Process group# Automatic Restart of the configuration file changes in progress Supervisor>Start Hellohello:startedsupervisor>Statushello RUNNING pid4125,Uptime 0:xx:Geneva# Anyway, these are the instructions, the output of the script will be logged to Stdout_logfile=specified log file # Now the case is, the program executes once and exits the supervisor>Statushello EXITED Dec on .: GenevaPmsupervisor> Exit
Shell > vim/etc/supervisord.conf[program:hello]directory=/Rootcommand=/bin/bash Hello.SHautostart=true; The program starts with Supervisord startup Startsecs=Ten; Program StartupTenafter not exiting, think the program started successfully startretries=3; start failed retry count AutoRestart=true; Automatically starts after the program exits,falseDo not start, unexpected only the exit status code is exitcodes=The specified value is only started automatically redirect_stderr=trueStdout_logfile=hello.logstdout_logfile_maxbytes=50MB stdout_logfile_backups=Ten# Add some configuration and re-supervisor>updatehello:stoppedhello:updated Process group# Note: This time it will be a bit longer because the startsecs is set=TenOther wordsTenseconds before status sees process status # this time the program will restart automatically.
Shell > vim/etc/supervisord.conf[program:hello]directory=/Rootcommand=/bin/bash Hello.SHProcess_name=% (program_name) s_%(Process_num) 02d; Set different process names when starting multiple processes Numprocs=2; start several processes autostart=trueStartsecs=5startretries=3AutoRestart=trueRedirect_stderr=trueStdout_logfile=hello.logstdout_logfile_maxbytes=50mbstdout_logfile_backups=Ten# plus the configuration to start multiple processes supervisor>updatehello:stoppedhello:updated Process Groupsupervisor>statushello:hello_00 RUNNING pid4899,Uptime 0:xx: thehello:hello_01 RUNNING pid4898,Uptime 0:xx: the# This time it's like this. Supervisor>Stop Allhello:hello_00:stoppedhello:hello_01:stoppedsupervisor>statushello:hello_00 STOPPED Dec on .: -pmhello:hello_01 STOPPED Dec on .: -pm#, all right, call it off!
Supervisor Process Management Tools