I am using Laravel queues and Redis with Horizon.
Supervisor is running artisan horizon
which in turn spawns processes /usr/bin/php7.2 artisan horizon:work redis
Is there need to run queue:work
at all or can Horizon already process the queue on its own?
With Horizon installed, the Artisan queue:work
and horizon:work
commands perform the same tasks, except that horizon:work
accepts arguments that it uses to coordinate with a Horizon supervisor.
When running the Horizon supervisor process (via artisan horizon
), we never need to execute horizon:work
manually. The horizon:work
command starts a queue worker process, and the supervisor runs it automatically when setting up worker pools.
By supervisor, I mean the Horizon manager process, not the system's supervisord which we use to start Horizon as a service.
In fact, horizon:work
is marked hidden, so we won't even see it in the available commands shown by artisan list
.
We can still execute artisan queue:work
manually to run a single, standalone queue worker that isn't managed by Horizon.
The artisan queue:work --once <connection>
command is more useful—this processes the next pending item in a queue and can help to debug misbehaving jobs in development.
For this to be effective, we need to run it after stopping any long-running queue workers so we can control when the job executes. Horizon makes this easy:
php artisan horizon:terminate