Linux: Supervisor
What is a "Supervisor"?
"Supervisor" is a process manager which provides a singular interface for managing and monitoring several long-running programs.
Run a PHP command using Supervisor
To run a PHP command using Linux Supervisor, you must follow the steps below:
Install "Supervisor"
sudo apt-get install supervisor
Create a "Supervisor" program configuration file:
sudo nano /etc/supervisor/conf.d/your_program.conf
Add the following content to the configuration file:
[program:your_program_name] command=your_command_here autostart=true autorestart=true stderr_logfile=/var/log/idle.err.log # Remove this line if "error log" isn't nedded stdout_logfile=/var/log/idle.out.log # Remove this line if "output log" isn't nedded
Save and close the file
Update the "Supervisor" configuration:
sudo supervisorctl reread
Next, run the command below, to update the "Supervisor" process group with any new or changed programs:
sudo supervisorctl update
Start the program:
sudo supervisorctl start your_program_name
To check the status of the program:
sudo supervisorctl status your_program_name
To stop the program:
sudo supervisorctl stop your_program_name
As a result, your PHP script should be run as a process managed by "Supervisor," which will restart it if it crashes or stops for any other reason.
Reference: How To Install and Manage Supervisor | DigitalOcean
Subscribe to my newsletter
Read articles from Al-Mooradi directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by