Introduced
Supervisord is a very useful process management tool implemented in Python.
Installation
Here with the source code
supervisor-3.1. 3. Tar . GZ tar -zxvf supervisor-3.1. 3. Tar . GZCD Supervisor-3.1. 3 sudo Install
To generate a default configuration file
echo_supervisord_conf >/etc/supervisord.conf
Modifying the default configuration file
To access the Wenb interface, modify the Inet_http_server configuration
[Inet_http_server] port=*:9001 ; here * indicates that other terminals can be accessed Supervisor Web interface username= Username; User name password=password ; Password
Command line control can be used
[Supervisorctl]serverurl=unix://tmp/supervisor.sock; Use a unix://URL for a Unix Socketserverurl=http://127.0.0.1:9001; use a http:// URL to specify an inet Socket
Modify Process
[Program:test_http]command=python test_http.py501; Monitored process path directory=/home/admin/soft/supervisor-3.1.3before the implementation of the CD to the directory, generally do not have priority=1. The higher the number, the higher the priorityNumprocs=1; start several processes autostart=true; starts with the Supervisord start AutoRestart=trueAuto Restart: Of course we have to choose Startretries.=Ten; The maximum number of times to start failure exitcodes=0The normal exit code (that is, the exit code is not restarted at this time?) Pending confirmation) Stopsignal=Kill ; a signal used for killing a process stopwaitsecs=Ten; wait time before sending Sigkill Redirect_stderr=true; REDIRECT stderr to stdout
Here test_http.py is located in directory (/home/admin/soft/supervisor-3.1.3)
test_http.py
Import sys import basehttpserver from simplehttpserver import Simplehttprequesthandler handlerclass=Simplehttprequesthandler ServerClass=Basehttpserver.httpserver Protocol="http/1.0" if__name__ = ="__main__": ifsys.argv[1:]: Port=int(sys.argv[1]) Else: Port=8000server_address= ('10.125.24.105', Port) Handlerclass.protocol_version=Protocol httpd=ServerClass (server_address, handlerclass) SA=httpd.socket.getsockname () print"serving HTTP on", sa[0],"Port", sa[1],"..."Httpd.serve_forever ()
Start
sudo Supervisord-c/etc/supervisord.conf
Management
Command Management
sudo supervisorctlstatus: View the currently running list of processes stop XXX: Stop a certain process (XXX), XXX for the value configured in [Program:theprogramname]. Start XXX: Start a process restart XXX: Restart a process stop Groupworker: Restart all processes that belong to the group named Groupworker (Start,restart same) Stop all, stop the whole process, Note: Start, restart, stop will not load the latest configuration file.
Reload the configuration file
sudo supervisorctl-c/etc/supervisord.conf
Interface Management
Linux Process management Tools--supervisor