Skip to content

Supervisor Commands ​

Supervisor is a process manager that keeps Laravel queue workers and other background processes running. It automatically restarts crashed processes.

🟠 MEDIUM RISK

Restarting Supervisor will interrupt all queue workers. Pending jobs will resume after restart.


Table of Contents ​

  1. Service Management
  2. Process Management
  3. Configuration
  4. Log Management
  5. Troubleshooting

Service Management ​

Check Supervisor Status ​

bash
sudo systemctl status supervisor

Start Supervisor ​

bash
sudo systemctl start supervisor

Stop Supervisor ​

🟠 QUEUE PROCESSING STOPS

Stopping Supervisor will stop all queue workers. SMS, emails, and background jobs won't process.

bash
sudo systemctl stop supervisor

Restart Supervisor ​

bash
sudo systemctl restart supervisor

Enable on Boot ​

bash
sudo systemctl enable supervisor

Process Management ​

View All Processes ​

bash
sudo supervisorctl status

Example Output:

laravel-worker:laravel-worker_00   RUNNING   pid 12345, uptime 2:30:45
laravel-worker:laravel-worker_01   RUNNING   pid 12346, uptime 2:30:45
horizon                            RUNNING   pid 12347, uptime 2:30:45

Start All Processes ​

bash
sudo supervisorctl start all

Stop All Processes ​

🟠 QUEUE STOPS

All background processing will stop.

bash
sudo supervisorctl stop all

Restart All Processes ​

bash
sudo supervisorctl restart all

Manage Specific Process ​

bash
# Start specific process
sudo supervisorctl start laravel-worker:*

# Stop specific process
sudo supervisorctl stop laravel-worker:*

# Restart specific process
sudo supervisorctl restart laravel-worker:*

Reload Configuration ​

bash
# After editing config files
sudo supervisorctl reread
sudo supervisorctl update

Add New Process ​

bash
sudo supervisorctl reread
sudo supervisorctl add process-name

Remove Process ​

bash
sudo supervisorctl remove process-name

Configuration ​

Configuration Directory ​

bash
ls -la /etc/supervisor/conf.d/

View Laravel Worker Config ​

bash
sudo nano /etc/supervisor/conf.d/laravel-worker.conf

Example Laravel Worker Config ​

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

Key Configuration Options ​

OptionDescription
numprocsNumber of worker processes
autostartStart when Supervisor starts
autorestartRestart if process dies
userRun as this user
stopwaitsecsWait time before force kill
stdout_logfileLog file location

After Config Changes ​

bash
sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl restart all

Log Management ​

View Process Logs ​

bash
# Tail specific process log
sudo tail -f /var/www/html/storage/logs/worker.log

# Or use supervisorctl
sudo supervisorctl tail -f laravel-worker:laravel-worker_00

View Supervisor Main Log ​

bash
sudo tail -f /var/log/supervisor/supervisord.log

Clear Worker Logs ​

bash
sudo truncate -s 0 /var/www/html/storage/logs/worker.log

Troubleshooting ​

Common Issues ​

Process Won't Start ​

bash
# Check config syntax
sudo supervisorctl reread

# Check process log
sudo supervisorctl tail laravel-worker:laravel-worker_00 stderr

# Check main log
sudo tail -50 /var/log/supervisor/supervisord.log

Process Keeps Restarting ​

bash
# Check if command is correct
php /var/www/html/artisan queue:work --help

# Check permissions
ls -la /var/www/html/artisan

# Check PHP errors
sudo tail -100 /var/log/php8.3-fpm.log

"FATAL Exited too quickly" ​

bash
# Process is crashing immediately
# Check the actual command manually:
cd /var/www/html
sudo -u www-data php artisan queue:work redis --tries=3

Socket Error ​

bash
# Check supervisor socket
ls -la /var/run/supervisor.sock

# Restart supervisor service
sudo systemctl restart supervisor

Useful Commands ​

bash
# Clear all process state
sudo supervisorctl clear all

# Get process info
sudo supervisorctl status laravel-worker:*

# Signal process (graceful stop)
sudo supervisorctl signal SIGTERM laravel-worker:*

Laravel Queue Restart ​

bash
# Gracefully restart queue workers (via Laravel)
cd /var/www/html
php artisan queue:restart

# This signals workers to finish current job then restart

Quick Reference Card ​

ActionCommand
Check statussudo supervisorctl status
Start allsudo supervisorctl start all
Stop allsudo supervisorctl stop all
Restart allsudo supervisorctl restart all
Reload configsudo supervisorctl reread && sudo supervisorctl update
View logssudo supervisorctl tail -f process-name
Service statussudo systemctl status supervisor
Service restartsudo systemctl restart supervisor
Config dir/etc/supervisor/conf.d/

www.onezeroart.com