DEV Community

Sudeep Mishra
Sudeep Mishra

Posted on

CostQ's Laravel jobs and Linux supervisor

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Step 3: Reload Supervisor and Start the Worker

sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl start laravel-worker:*
Enter fullscreen mode Exit fullscreen mode

πŸ§ͺ Check if It's Running

sudo supervisorctl status
Enter fullscreen mode Exit fullscreen mode

Use logfile for debugging queue errors.

Cheers !!! Happy CODING

Top comments (0)