Skip to main content

email-configuration


title: Email & Queue Worker Setup

Steps to Run Queue Worker on Server

Laravel queues must be running on the server to process background jobs such as:

  • Emails
  • Notifications
  • Scheduled tasks
  • Background processing

Option 1: Supervisor (Recommended for Production)

Step 1: Install Supervisor

sudo apt-get install supervisor

Step 2: Create Supervisor Config File

sudo nano /etc/supervisor/conf.d/tadreeblms-worker.conf

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

Step 3: Start Supervisor

sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl start tadreeblms-worker:*

Step 4: Verify Status

sudo supervisorctl status

Option 2: Cron-Based (Simpler Alternative)
crontab -e
* * * * * cd /var/www/tadreeblms && php artisan queue:work --stop-when-empty --tries=3 >> /dev/null 2>&1
* * * * * cd /var/www/tadreeblms && php artisan schedule:run >> /dev/null 2>&1

After Deployment Restart

sudo supervisorctl restart tadreeblms-worker:*(for-supervisor)
php artisan queue:restart(for-cron)

Quick Summary

Supervisor

  • Always running
  • Auto-restart
  • Reliable
  • Needs root access

Cron

  • Simple
  • No extra software
  • 1-minute delay between batches