DevOps & Deployment

Supervising application queue workers with systemd

Keep long-running workers manageable across crashes and deployments.

Anant Dhiman · · 1 min read

Linux server with supervised background queue processing
On this page

A queue worker started in a terminal is vulnerable to logout and accidental termination. Production workers need supervision, predictable restart behavior and visible logs.

Implementation approach

Run the worker as a dedicated unprivileged service account, set its working directory and environment, and choose restart and shutdown settings that suit the job timeout.

Example

[Service]
User=www-data
WorkingDirectory=/var/www/example
ExecStart=/usr/bin/php artisan queue:work
Restart=on-failure

Validation and edge cases

Check service status and journal output, simulate a worker failure and verify graceful shutdown during a deployment. Align queue retry timing with worker timeout to limit duplicate processing.

Key takeaway

This is a service fragment, not a complete unit; define installation, permissions and operational procedures for the actual environment.

← All insights

Related articles