The Supervisor's server is called supervisord. It is mainly responsible for starting the management sub-processes when it starts itself, responding to client commands, restarting the crashed or exited sub-processes, recording the sub-processes stdout and stderr output, generates and processes events in the subprocess lifecycle. You can configure relevant parameters in a configuration file, including the status of Supervisord and the attributes of each sub-process managed by Supervisord. The configuration file is generally located in/etc/supervisord. conf.
The supervisorctl client provides a shell-like interface (that is, a command line) to use the functions provided by the supervisord server. With supervisorctl, you can connect to the supervisord server process to obtain the status of the sub-process controlled by the server process, start and stop the sub-process, and obtain the list of running processes. The client communicates with the server through a Unix domain socket or TCP socket. The server has an identity authentication mechanism, which can effectively improve security. When the client and the server are on the same machine, the client and the server share the same configuration file/etc/supervisord. conf. Different labels are used to differentiate the configurations of the two.
Supervisor also provides a web page to view and manage the process status, which is rarely used.
Official website: http://www.supervisord.org
1. Install supervisord
$ Brew install supervisord
Installation on mac is much easier than installation on linux.
II. Configuration
Modify the/usr/local/etc/supervisord. Ini file and cancel the following comments:
[Inet_http_server]; inet (TCP) server disabled by default
Port = 127.0.0.1: 9001; (ip_address: port specifier, *: port for all iface)
Username = user; (default is no username (open server ))
Password = 123; (default is no password (open server ))
In this way, you can manage it in a browser.
3. Add a new application
Create a. Php file with the following content:
While (true ){
Echo 'A'. time (). "\ r \ n ";
Sleep (1 );
}
Add the following lines to the supervisord. Ini file:
[Program: php]
Command = php/Users/sxf/web/a. php
Autostart = true
Autorestart = true
Startsecs = 1
Startretries = 3
Redirect_stderr = true
Stdout_logfile =/Users/sxf/web/supervisord. log
Stderr_logfile =/Users/sxf/web/stderr. log
Restart supervisord.
$ Brew services restart supervisord
Open the browser http: // 127.0.0.9001 and enter the user name and password. You can view the process and stop, restart, and refresh each process.