Skip to content

Queue Workers

XetaSuite uses Laravel queues for asynchronous tasks: sending emails, generating reports, etc.

Terminal window
QUEUE_CONNECTION=redis
REDIS_HOST=127.0.0.1
REDIS_PORT=6379
Terminal window
QUEUE_CONNECTION=database

Create the jobs table:

Terminal window
php artisan queue:table
php artisan migrate
Terminal window
php artisan queue:work

Use a process manager to keep workers running.

Create /etc/supervisor/conf.d/xetasuite-worker.conf:

[program:xetasuite-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/xetasuite-core/artisan queue:work redis --sleep=3 --tries=3 --max-time=3600
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
user=www-data
numprocs=2
redirect_stderr=true
stdout_logfile=/var/www/xetasuite-core/storage/logs/worker.log
stopwaitsecs=3600

Enable:

Terminal window
sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl start xetasuite-worker:*
Terminal window
php artisan queue:monitor redis:default
Terminal window
php artisan queue:failed
Terminal window
# Retry all
php artisan queue:retry all
# Retry specific
php artisan queue:retry 5
Terminal window
php artisan queue:flush
Terminal window
php artisan queue:restart

This command signals workers to gracefully restart after finishing their current job.

For more advanced queue management, consider using Laravel Horizon:

Terminal window
composer require laravel/horizon
php artisan horizon:install
php artisan migrate

Run Horizon:

Terminal window
php artisan horizon

Access the dashboard at /horizon.