Queues are used to defer the processing of 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.
Please note that this configuration is only for those running the application in a virtual private server or a hosting platform that meets the requirements listed below. If your server doesn't meet the requirements, simply disable queues by adding QUEUE_DRIVER=sync
to the .env file.
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 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
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:
[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.
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:*
Siempre puedes ponerte en contacto si no encuentras lo que estás buscando en nuestro centro de ayuda. ¡Te responderemos tan pronto sea posible!
Siempre puedes ponerte en contacto si no encuentras lo que estás buscando en nuestro centro de ayuda. ¡Te responderemos tan pronto sea posible!
Contáctenos