Supervisor Configuration
Installing Supervisor
Supervisor is a process monitor for the Linux operating system, and will automatically restart your queue:work
process if it fails. To install Supervisor on Ubuntu, you may use the following command:
sudo apt-get install supervisor
If configuring Supervisor yourself sounds overwhelming, consider using Laravel Forge, which will automatically install and configure Supervisor for your Laravel projects.
Configuring Horizon
Supervisor configuration files are typically stored in the /etc/supervisor/conf.d
directory. Within this directory, you may create any number of configuration files that instruct supervisor how your processes should be monitored. For example, let's create a horizon.conf
file that starts and monitors a horizon
process:
[program:horizon]
process_name=%(program_name)s
command=php /var/www/html/cryptoexchange/artisan horizon
autostart=true
autorestart=true
user=root
redirect_stderr=true
stdout_logfile=/var/log/horizon.log
Replace ​cryptoexchange
​to your project directory name. If your server does not have root
user, then change the user
as well. Make sure /var/log/horizon.log
the file is created and has write permission
Starting Supervisor
Once the configuration file has been created, you may update the Supervisor configuration and start the processes using the following commands:
sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl start horizon
You need to run the following command to check if your supervisor is running successfully.
sudo supervisorctl status