CostQ is a cloud cost optimization platform, and I have been involved in building it from scratch. From database schemas to API endpoints, we made sure that the platform remains secure and scalable while functioning at every hand of clock.
At its core, background jobs are configured into a queue powered by Laravel, MySQL and Linux supervisor.
π Why Use Supervisor for Laravel Queues?
Supervisor is a process manager that ensures your queue worker runs continuously.
- π‘οΈ Always-On β Keeps your queue workers alive 24/7, auto-restarts if they crash.
- π§ Set & Forget β Boots with your server, no need to baby-sit processes.
- π§Ύ Logs FTW β Built-in log support for easy debugging.
- π§© Scalable β Run multiple workers with one config.
- π― Snappy Performance β No reload per job like queue:listen.
- ποΈ Full Control β Start, stop, restart workers like a boss.
- π οΈ Production-Ready β Battle-tested. Simple. Reliable.
Configuring
Step 1: Install Supervisor
sudo apt update
sudo apt install supervisor
Step 2: Create a Config File for Laravel Queue
Created a new configuration file for Laravel queue worker:
sudo nano /etc/supervisor/conf.d/laravel-worker.conf
File Contents:
[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /path/to/laravel/project/artisan queue:work --sleep=3 --tries=3 --timeout=90
autostart=true
autorestart=true
user=www-data
numprocs=1
redirect_stderr=true
stdout_logfile=/path/to/laravel/project/storage/logs/laravel-queue.log
Step 3: Reload Supervisor and Start the Worker
sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl start laravel-worker:*
π§ͺ Check if It's Running
sudo supervisorctl status
Use logfile for debugging queue errors.
Cheers !!! Happy CODING
Top comments (0)