Installing and configuring a supervisor in Debian to execute a Laravel queue worker

I need to install and configure a supervisor in Debian to continuous execute a queue worker.

The system is a Debian 8.

$ sudo lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 8.11 (jessie)
Release: 8
Codename: jessie

I will use Supervisor, a process control system that allows to monitor and control a number of processes on UNIX-like operating systems.

If my process shuts down, the supervisor will start it.

First I install the supervisor

$ sudo apt-get install supervisor -y

Then I create the configuration file for this worker in the /etc/supervisor/conf.d folder: my-project-queue.conf

[program:my-project-queue-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /home/my-project/www/artisan queue:work
autostart=true
autorestart=true
user=my-project-user
numprocs=1
redirect_stderr=true
stdout_logfile=/home/my-project/www/storage/logs/my-project-queue-worker.log

You can get more information about these parameters on the official webpage of the Supervisor project. Two important parameters:

  • «command=php /home/my-project/www/artisan queue:work» is the process that I want to supervise.
  • «stdout_logfile=/home/my-project/www/storage/logs/my-project-queue-worker.log» is the log file for this supervision.

Once I have finished the configuration I have to reload the configuration. I execute the command

$ sudo supervisorctl update

that reload the config and add/remove as necessary, and will restart affected programs.

You can get more information in the Laravel official documentation.

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

Este sitio usa Akismet para reducir el spam. Aprende cómo se procesan los datos de tus comentarios.