Use supervisord to monitor php script status configuration

Source: Internet
Author: User
Tags php file php script socket unix domain socket

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.