Queue Workers
Optional background job processing for backup, update, and rollback operations.
TL;DR
Run php spark queue:work pubvana as a long-running process (via systemd or Supervisor). Without a queue worker, Pubvana falls back to exec() or synchronous execution — which works for most sites. Queue workers are only needed for high-traffic sites or guaranteed async processing.
Details
What the Queue Is For
Pubvana uses the codeigniter4/queue package for three heavy operations that should not block a web request:
- Backup — creating a full site backup can take 30–120 seconds.
- Update — downloading and applying a CMS update can take 60–180 seconds.
- Rollback — restoring from a backup can take 30–120 seconds.
When an admin triggers one of these from the web UI, Pubvana tries three dispatch methods in order:
- Queue — if
php spark queue:work pubvanais running, the job is pushed to the queue and processed asynchronously in the background. The admin UI polls for progress via SSE. - exec() — if PHP
exec()is available (not disabled inphp.ini), Pubvana spawns a background Spark command. No queue worker needed. - Synchronous — runs inline with
set_time_limit(300)as a last resort. The web request blocks until the operation completes.
Queue Configuration
The queue is configured in app/Config/Queue.php. The default handler is database, which uses the default database connection and stores jobs in the queue_jobs table. Alternative backends that can be configured:
- Redis — recommended for high-throughput sites. Requires the
predis/predispackage. - Predis — alias for Redis using the Predis library.
- RabbitMQ — for enterprise message queue setups.
Failed jobs are preserved (keepFailedJobs = true) and can be inspected in the queue_failed_jobs table.
Running the Queue Worker
For development or quick testing:
php spark queue:work pubvana
For production, keep the worker running continuously. Example systemd unit file (/etc/systemd/system/pubvana-queue.service):
[Unit]
Description=Pubvana Queue Worker
After=network.target
[Service]
User=www-data
WorkingDirectory=/var/www/html
ExecStart=/usr/bin/php /var/www/html/spark queue:work pubvana
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
Enable and start:
systemctl enable pubvana-queue
systemctl start pubvana-queue
Alternatively, use Supervisor to manage the process. Add a [program:pubvana-queue] entry to your Supervisor config pointing to php spark queue:work pubvana.
Do I Need a Queue Worker?
For most Pubvana installations: no. The exec() fallback handles async operations without any additional infrastructure. Consider running a queue worker only if:
- PHP
exec()is disabled on your server. - You have high traffic and want guaranteed non-blocking admin operations.
- You want centralised job failure tracking and retry logic.