Laravel
Horizon
Run Laravel Horizon as its own container with php artisan horizon. Horizon starts and supervises your Redis queue workers, so it replaces queue:work containers.
Compose example
Horizon needs Redis. Configure the connection in your application's .env.
compose.yml
services:
app:
image: my-org/my-app:1.0.0
ports:
- "80:8080"
horizon:
image: my-org/my-app:1.0.0
command: ["php", "artisan", "horizon"]
stop_signal: SIGTERM
healthcheck:
test: ["CMD", "healthcheck-horizon"]
start_period: 10s
depends_on:
- redis
redis:
image: redis:8-alpine
stop_signal and the health check are required on every worker. With SIGTERM, Horizon finishes its current jobs before it exits. Running workers explains why.
Health check
healthcheck-horizon runs php artisan horizon:status. It fails when no Horizon process is running or when Horizon is paused.