Skip to content

Workers & CLI Commands ​

jengo/queues includes CLI commands for processing queues, monitoring queue health, and managing workers.


Starting the Worker Daemon ​

Run the jengo:queue work command to start the worker process:

bash
php spark jengo:queue work

Worker Options ​

bash
# Work a specific connection (e.g. redis or database)
php spark jengo:queue work redis

# Specify queue priority order (comma-separated)
php spark jengo:queue work redis --queue=high,default,low

# Control sleep when idle (seconds)
php spark jengo:queue work --sleep=5

# Set maximum attempts before marking as failed
php spark jengo:queue work --tries=3

# Set memory limit ceiling in megabytes
php spark jengo:queue work --memory=256

# Process a specific number of jobs and exit
php spark jengo:queue work --max-jobs=100

Processing Single Jobs (listen) ​

The listen command processes incoming jobs synchronously:

bash
php spark jengo:queue listen redis --queue=default

Clearing Queues ​

Delete all pending jobs from a queue:

bash
# Clear default queue on default connection
php spark jengo:queue clear

# Clear specific queue without confirmation prompt
php spark jengo:queue clear redis --queue=emails --force

Checking Queue Status ​

Check the health and pending job counts of a connection:

bash
php spark jengo:queue status database
php spark jengo:queue status redis

Production Process Supervision (Supervisor) ​

For production environments, use Supervisor or systemd to keep worker daemons running continuously:

ini
[program:jengo-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/my-app/spark jengo:queue work redis --queue=high,default --tries=3
autostart=true
autorestart=true
user=www-data
numprocs=4
redirect_stderr=true
stdout_logfile=/var/www/my-app/writable/logs/worker.log

Released under the MIT License.