Skip to content
Fossil edited this page Oct 9, 2019 · 2 revisions

Laravel Horizon redis queues and jobs monitoring

NNTmux uses laravel horizon to monitor redis queues and jobs.

This can be triggered manually by running php artisan horizon command, but that requires manual check and is not recommended way.

What we suggest is to use supervisor.

Installing and configuring supervisor

This is taken from laravel docs, https://laravel.com/docs/5.7/horizon#running-horizon and addapted for our use case.

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

Configuring Supervisor

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 laravel-horizon.conf file that starts and monitors a horizon process:

[program:laravel-horizon]

process_name=%(program_name)s

command=php /var/www/NNTmux/artisan horizon

autostart=true

autorestart=true

user=your user here

redirect_stderr=true

stdout_logfile=/var/www/NNTmux/storage/logs/horizon.log

In this example, the numprocs directive will instruct Supervisor to run 8 queue:work processes and monitor all of them, automatically restarting them if they fail. Of course, you should change the queue:work sqs portion of the command directive to reflect your desired queue connection.

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 laravel-horizon:*

For more information on Supervisor, consult the Supervisor Documentation.

For more information on Laravel Horizon, consult Laravel Horizon Documentation.