Supervisor from Getting Started to Giving Up

  php, Process, supervisor



Supervisor is a client/server system that allows its users to control many processes on UNIX-like operating systems. (Official Interpretation)

Simply put, it is a tool to monitor the running of scripts, but it can be managed in a unified way. laravel’s queue documents also have relevant usage methods, such as

  • Start, restart, shutdown and log monitoring of timed scripts
  • Swoole’s startup, restart, shutdown, and log monitoring (it is well known that most of its features can only be run in cli)
  • Redis startup, restart, shutdown, and log monitoring (redis itself does not provide a background visualization tool similar to phpmyadmin)
  • Queues in laravel, some automated scripts, scripts for workman, etc

Generally used&test.shLet it run in the background, but in many cases, it is impossible to monitor scripts individually. At this time, you may need a Supervisor to help you. You can use it as the visual management background of your unix system. Now let’s witness its strength.


Supervisor can be installed in many ways, and I recommend the simplest and easiest one.

apt-get -y install python-setuptools
 easy_install supervisor

As you can see, the two commands complete the installation.


After Supervisor installation is completed, runecho_supervisord_conf. This will print an example Supervisor configuration file to your terminal. As long as you can see the printed profile content.

Supervisor does not automatically generate configuration files.

Please use the commandecho_supervisord_conf > /etc/supervisord.confTo generate a configuration file.

Partial Profile Information Table

Name Notes Chestnut
inet_http_server[port] Built-in management background *:8888
inet_http_server[username] Management background user name admin
inet_http_server[password] Manage background passwords admin
include[files] Setting Process Profile Format /etc/supervisor/supervisor.d/*.ini


Supervisor startup requires configuration files to be loaded

supervisord -c /etc/supervisor/supervisord.conf

The stop command is

supervisorctl shutdown

Reload configuration file

supervisorctl reload

Supervisor to[program:[your_cli_name]]At the beginning of each process configuration file, your_cli_name is your process name, which will be displayed on the Supervisor background management tool and Supervisor cli command output. Let’s take php-fpm as an example.


Oh, it is simple. There is not too much nonsense. Or run a shell.

 your_name="my name zhangsan"
 echo $your_name

Of course, the laravel queue is still simple

 command=php /home/forge/ queue:work sqs --sleep=3 --tries=3

Of course, this is only a simple demonstration so that you can get started quickly. command is not the only command in the configuration script.
See official documents for details. …


Supervisor provides simple background management


The general functions include restarting, starting, stopping processes, printing logs, clearing logs, etc. Basically, there are only a few simple functions, and of course there is no downtime alarm, log alarm, etc. However, the powerful Supervisor provides us with an interface.


Through API, all basic information can be obtained, such as process list, status of a process and process log. Including the restart, stop and start of the process, there is no problem in completely integrating the Supervisor into the internal monitoring background.

Please move to the official website Api document for details …


Finally, I gave a simple script to my friends for learning Supervisor.

#!  /bin/bash
 set -x
 case $1 in
 if [[ $2 == 'start' ]];  then
 "supervisord -c /etc/supervisor/supervisord.conf"
 elif [[ $2 == 'stop' ]];  then
 "supervisorctl shutdown"
 elif [[ $2 == 'restart' ]];  then
 "supervisorctl shutdown"
 "supervisord -c /etc/supervisor/supervisord.conf"
 elif [[ $2 == 'reload' ]];  then
 "supervisorctl reload"
 ;  ;

You can use this simple script to quickly start, restart, and close the Supervisor.

Sh sp start // start
 Sh sp restart // restart

Thank you

Thank you for seeing here. I hope this chapter can help you. Thank you