Setting Up Supervisor for the Job Queue

Introduction

To ensure background queue tasks are processed continuously in production, it is highly recommended to run the Zero CMS Job Queue Runner as a monitored background daemon using **Supervisor**. Supervisor acts as a process manager that launches our executable binary on boot and automatically restarts it if it crashes, runs out of memory, or encounters system bottlenecks.

Supervisor Configuration

Create a new Supervisor configuration file under /etc/supervisor/conf.d/zero-queue.conf:

[program:zero-queue-worker]
process_name=%(program_name)s_%(process_num)02d
directory=/data/misc/zero/
command=php bin/queue-runner
autostart=true
autorestart=true
user=www-data
numprocs=1
redirect_stderr=true
stdout_logfile=/data/misc/zero/storage/logs/queue-worker.log

Activating the Daemon

To register, load, and launch your newly configured process manager, execute the following commands in your server terminal:

# Reread and discover new configuration files
sudo supervisorctl reread

# Add and start the newly discovered background worker
sudo supervisorctl update

# Verify the status and verify that the daemon is active and running
sudo supervisorctl status

Monitoring and Log Rotation

All standard outputs, processing durations, and exceptions are logged directly to /data/misc/zero/storage/logs/queue-worker.log. To prevent this file from expanding infinitely over time, configure standard log rotation under /etc/logrotate.d/zero-queue:

/data/misc/zero/storage/logs/queue-worker.log {
    weekly
    missingok
    rotate 12
    compress
    notifempty
    sharedscripts
}