[Supervisor] Note (Getting Started)
I haven't used it for a long time. I 'd like to talk about the installation and make a simple experiment. The system is Ubuntu14.04.
Quick configuration Installation
Sudo pip_python install supervisorsudo echo_supervisord_conf>/etc/supervisord. conf # the following error occurs: permission denied:/etc/supervisord. conf, you can use the following statement sudo su-root-c "echo_supervisord_conf>/etc/supervisord. conf"
In this way, an original configuration file is generated, but some changes need to be made
sudo vim /etc/supervisord.conf
...[unix_http_server]file=/var/run/supervisor.sock ; (the path to the socket file)...[supervisord]logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)...[supervisorctl]serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL for a unix socket...[include]files = /etc/supervisord.d/*.ini
Note that in unix_http_server and supervisorctlSockFile directory must be consistent
Then create a directory
Sudo su-root-c "mkdir-p/etc/supervisord. d"
Then, place the process management script to supervisord. d.
The following is a simple example.
First, write a test script.
#!/usr/bin/python#-*- coding:utf-8 -*-#############################File Name: somejob.py#Author: orangleliu#Mail: orangleliu@gmail.com#Created Time: 2015-04-15 11:08:13#License: MIT############################import sys, timewhile True: print "pyserver runing %s"%time.ctime() sys.stdout.flush() time.sleep(10)
Configure a process management script in the/etc/supervisord. d directory.
somejob.ini
[program:somejob]command=/usr/bin/python /home/lzz/temp/super/somejob.pydirectroy=/home/lzz/temp/super/autostart=trueautorestart=truestartretries=3user=lzzstdout_logfile=/home/lzz/temp/super/%(program_name)s.logstderr_logfile=/home/lzz/temp/super/%(program_name)s.log
Operation
Supervisord startup
sudo /usr/local/bin/supervisord -c /etc/supervisord.conf lzz@ubuntu:supervisord.d$ ps -ef|grep superroot 5709 1 0 11:30 ? 00:00:00 /usr/bin/python /usr/local/bin/supervisord -c /etc/supervisord.conflzz 5710 5709 0 11:30 ? 00:00:00 /usr/bin/python /home/lzz/temp/super/somejob.py
Check that my job process has been started and the log file is normal.
lzz@ubuntu:super$ tail somejob.log pyserver runing Wed Apr 15 11:31:47 2015pyserver runing Wed Apr 15 11:31:57 2015pyserver runing Wed Apr 15 11:32:07 2015
Supervisord overload
supervisorctl rereadsupervisorctl update
Process view
lzz@ubuntu:super$ sudo supervisorctl somejob RUNNING pid 6021, uptime 0:00:13
Process overloadModify the job Program to see the effect
sudo supervisorctl reload somejob
View logs
pyserver runing Wed Apr 15 11:44:22 2015hipyserver runing Wed Apr 15 11:44:32 2015hipyserver runing Wed Apr 15 11:44:38 2015pyserver runing Wed Apr 15 11:44:48 2015
Process closed
Sudo supervisorctl stop somejob # start it here
View Processes
lzz@ubuntu:super$ ps -ef|grep superroot 6020 1 0 11:41 ? 00:00:00 /usr/bin/python /usr/local/bin/supervisord -c /etc/supervisord.conf
There is also a part of the web interface for process management, as well as boot, etc. You can view the documentation or google