It is a server-side process management container that is designed for permanent process handling. The container is the container that is designed to run the viewing, loading, and other commands.

I. Supervisor Installation

pip install supervisor
Copy the code

Or is it

yum install supervisor  # centos
sudo apt-get install supervisor  # ubuntu
Copy the code

Supervisor configuration

Creating a folder

mkdir -p /etc/supervisor/
mkdir -p /etc/supervisor/supervisord.d/
Copy the code

Generating a Configuration File

echo_supervisord_conf > /etc/supervisor/supervisord.conf
Copy the code

Editing a Configuration File

vim /etc/supervisor/supervisord.conf
Copy the code

Use the default configuration except for the last two lines in the configuration file. In vim, use G to jump the cursor to the end of the file and change the last line to the following.

[include]
files = /etc/supervisor/supervisord.d/*.conf
Copy the code

Creating a startup script

vim /etc/supervisor/supervisord.d/shopApi.conf
Copy the code

Start script Contents Notice Change the path of the project artisan file

[program:xmshop-api]
process_name=%(program_name)s_%(process_num)02d
command=php /mnt/www/xmshopApi/artisan queue:work --tries 3 --sleep 3
autostart=true
autorestart=true
user=root
numprocs=1
redirect_stderr=true
stdout_logfile=/mnt/www/shopApi/storage/logs/supervisor.log
Copy the code

Start the Supervisor

# It is running the container service
supervisord -c /etc/supervisor/supervisord.conf

supervisorctl reload  # restart supervisord
supervisorctl reread  It is designed to re-read the configuration file container
supervisorctl start lumen_worker:*  Start the lumen_worker service

supervisorctl restart lumen_worker:*  Restart the lumen_worker service
Copy the code

Check the running status once you start

supervisorctl status
Copy the code

Make sure you restart the file after modifying it. Reread doesn’t work