Laravel Horizon Zero Processes Running
I just spent the past two hours trying to figure out why my latest deployment to our dev environment didn't have any Horizon queue workers running. I finally figured out my issue, so here's a lil write up in case you are experiencing the same.
At SafetyTek we are running two queue servers, one for
production and one for our
dev environment. Both had been working fine up until today when I was making some changes.
Earlier in the day I had adjusted the
.env file of our dev environment to have
APP_ENV=dev instead of
APP_ENV=production so that we can disable certain production-only loggers.
At some point after this I was bouncing around our application and noticed that certain actions weren't happening so I decided to hop into the horizon dashboard to see a backlog of jobs and no processes running to consume those jobs.
I spent hours editing configs, hunting down logs, rebooting the server, restarting processes.
As it turns out, in
config/horizon.php there is a configuration key called
environments that allows you to configure certain process settings based on the
APP_ENV you have set.
So our production one was still working fine since the
production environment was configured here, but since there was no
dev key it reads that as "don't start any processes".
The fix is just adding a key for whatever your
APP_ENV is set to
'environments' => [ 'production' => [ 'supervisor-1' => [ 'maxProcesses' => 10, 'balanceMaxShift' => 1, 'balanceCooldown' => 3, ], ], 'dev' => [ 'supervisor-1' => [ 'maxProcesses' => 10, 'balanceMaxShift' => 1, 'balanceCooldown' => 3, ], ], 'local' => [ 'supervisor-1' => [ 'maxProcesses' => 3, ], ], ]
Hopefully this saves someone else a headache!