I. installation and configuration of environments such as golang and beego II. Installation of supervisor
GitHub address: https://github.com/Supervisor/supervisor
Clone project: git clone https://github.com/Supervisor/supervisor.git
Go to project: CD Supervisor
Installation: Python setup. py install
Iii. Supervisor configuration file
Official documentation-Configuration
vi /etc/supervisord.conf
[Supervisord] http_port =/var/tmp/supervisor. sock; (default is to run a Unix domain socket server); http_port = 127.0.0.1: 9001; (alternately, ip_address: Port specifies af_inet); sockchmod = 0700; af_unix socketmode (af_inet ignore, default 0700); sockchown = nobody. nogroup; af_unix socket uid. GID owner (af_inet ignores); umask = 022; (process file creation umask; default 022) logfile =/var/log/Supervisor/supervisord. log; (supervisor output log, main log file; default $ CWD/supervisord. log) logfile_maxbytes = 50 MB; (max main logfile bytes B4 rotation; default 50 MB) logfile_backups = 10; (Num of main logfile rotation backups; default 10) loglevel = Info; (logging level; default Info; others: Debug, warn) pidfile =/var/run/supervisord. PID; (supervisord pidfile; default supervisord. PID) nodaemon = false; (start in foreground if true; default false) minfds = 1024; (min. avail Startup file descriptors; default 1024) minprocs = 200; (min. avail process descriptors; default 200); nocleanup = true; (don't clean up tempfiles at start; default false); http_username = user; (default is no username (Open System); http_password = 123; (default is no password (Open System); childlogdir =/tmp; ('auto' child log Dir, default $ temp); User = chrism; (default is current user, required if root); directory =/tmp; (default is not to CD during start ); environment = Key = value; (key value pairs to add to Environment) [supervisorctl] serverurl = Unix: // var/tmp/supervisor. sock; use a Unix: // URL for a UNIX socket; serverurl = http: // 127.0.0.1: 9001; use an http: // URL to specify an Inet socket; username = Chris; shocould be same as http_username if set; Password = 123; shocould be same as http_password if set; prompt = mysupervisor; cmd line prompt (default "supervisor ") [unix_http_server] file =/var/tmp/supervisor. sock; (the path to the socket file); chmod = 0777; socket file mode (default 0700); chown = root: root; socket file uid: GID owner; username = root; (default is no username (Open Server); Password = root; (default is no password (Open Server) [inet_http_server] Port = 127.0.0.1: 9001 [rpcinterface: Supervisor] supervisor. rpcinterface_factory = supervisor. rpcinterface: make_main_rpcinterface [Program: Hello]; you can configure the program directory to be managed here =/home/www/PHP/; command =/usr/bin/PHP test. PHP; process_name = % (program_name) s; numprocs = 1; autostart = true; startsecs = 1; autorestart = true; startretries = 3; user = root; redirect_stderr = true; stdout_logfile_maxbytes = 20 mb; stdout_logfile_backups = 10; [include]; you can also include the program configuration file files =. /Supervisor/CONF. d /*. INI;
vi /etc/supervisor/conf.d/wx-prj.ini
[Program: WX-prj]; directory =/home/www/go/src/wx-prj; go project directory; command =/home/www/go/src/wx-prj; directory of the executable file compiled by the Go project =/home/www/go/bin; command =/home/www/go/bin/wx-prj; process_name = % (program_name) s; numprocs = 1; autostart = true; startsecs = 1; autorestart = true; startretries = 3; user = root; redirect_stderr = true; stdout_logfile =/home/www/go/wx-prj.stdout.log; print standard output log stdout_logfile_maxbytes = 20 mb; stdout_logfile_backups = 10; stderr_logfile =/home/www/go/wx-prj.stderr.log; print stderr_logfile_maxbytes = 20 mb; stderr_logfile_backups = 10; log_stdout = true; if true, log program stdout (default true) log_stderr = true; if true, log program stderr (DEF false)
4. Start the supervisor Service
supervisord -c /etc/supervisord.conf
When starting the service, you can track the log output and observe [[email protected] Go] # tail-F/var/log/Supervisor/supervisord. log2018-10-26 13:36:30, 881 info sorted ded extra file "/etc /. /Supervisor/CONF. d/wx-prj.ini "during parsing2018-10-26 13:36:30, 902 info RPC interface 'supervisor 'initialized2018-10-26 13:36:30, 902 crit server 'inet _ http_server' running without any HTTP Authentication checking2018-10-26 13:36:31, 203 info RPC interface 'supervisor 'initialized2018-10-26 13:36:31, 203 crit server 'unix _ http_server' running without any HTTP Authentication checking2018-10-26 13:36:31, 206 info daemonizing the supervisord process2018-10-26 13:36:31, 207 info supervisord started with PID 170402018-10-26 13:36:32, 209 info spawned: 'hello' with PID 170412018-10-26 13:36:32, 213 info spawned: 'wx-prj' with PID 170422018-10-26 13:36:32, 219 info spawned: 'World' with PID 170432018-10-26 13:36:33, 279 info success: Hello entered running state, process has stayed up for> than 1 seconds (startsecs) 13:36:33, 279 info success: WX-prj entered running state, process has stayed up for> than 1 seconds (startsecs) 13:36:33, 279 info success: World entered running state, process has stayed up for> than 1 seconds (startsecs)
You can also run the command to view the [[email protected] Conf. d] # supervisorctl statushello running PID 17041, uptime 0: 00: 19 World running PID 17043, uptime 0: 00: 19wx-prj running PID 17042, uptime 0:00:19
5. Reload the configuration modified by the supervisor
supervisorctl reload
6. Stop/start/restart programs managed by the supervisor
[[email protected] conf.d]# supervisorctl stop wx-prjwx-prj: stopped[[email protected] conf.d]# supervisorctl start wx-prjwx-prj: started[[email protected] conf.d]# supervisorctl restart wx-prjwx-prj: stoppedwx-prj: started[[email protected] conf.d]# supervisorctl stop allhello: stoppedwx-prj: stoppedworld: stopped[[email protected] conf.d]# supervisorctl start allhello: startedwx-prj: startedworld: started
Configure supervisor to manage beego applications