Configure the queues system

Queues are used to defer the processing of a time consuming tasks, such as sending emails, until a later time. Deferring these time consuming tasks drastically speeds up the requests, making the user experience better.

The queues system is powered by Laravel Queues.

What you will need

  1. SSH access to your server
  2. Root or sudo access (sudo is recommended)
  3. Supervisor installed on your server

For this guide, we assume that the help desk is installed at /var/www/fullhelp/live.

In order for the queued tasks to be executed, the php artisan queue:work command should be executed at the root directory of the installation. Note that once the queue:work command has started, it will continue to run until it is manually stopped or you close your terminal.

To keep the queue:work process running permanently in the background, we will use the process monitor, Supervisor, to ensure that the queue worker does not stop running.

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

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 fullhelp.conf file that starts and monitors a queue:work process:

If the file already exists, add the following code to the bottom, or create a new one.
[program:fullhelp-queue]
process_name=%(program_name)s_%(process_num)02d
command=/usr/bin/php /var/www/fullhelp/live/artisan queue:work --sleep=3 --tries=3
autostart=true
autorestart=true
user=www-data
numprocs=2
redirect_stderr=true
stdout_logfile=/var/www/fullhelp/live/storage/logs/worker.log

Make sure to replace /var/www/fullhelp/live with the path to your own installation. Feel free to adjust any of the values as you need.

Starting Supervisor

Once the configuration file has been created (or updated), start the processes using the following commands:

sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl start fullhelp-queue:*
Your vote was sent, thanks!
Was this article helpful?

Want to talk to a human?

Feel free to contact us if you cannot find what you are looking for in our help center. We will be answering you shortly!

Feel free to contact us if you cannot find what you are looking for in our help center. We will be answering you shortly!

Contact us
Woman messaging on mobile phone