If you're like me you tend to have a staging and production instance of your code on the same server. Recently I've been running into an issue where my Laravel Horizon queues were not processing when I had multiple instances of Horizon on the same server. Here's how I fixed that issue:
config/horizon.php file you'll need to create a new environment for your staging environment. There should be one for local and production already but nothing for staging. Create that
1'staging' => [2 'supervisor-staging' => [3 'connection' => 'redis',4 'queue' => ['queue.staging'], // Use a unique name for your staging queue5 'balance' => 'simple',6 'processes' => 3,7 'tries' => 38 ],
Once that is done we'll want to use a different Redis database than our production application uses so we don't have any collisions with the queues. Head over to your
config/database.php file and add some values under the
1'options' => [2'prefix' => env('REDIS_PREFIX', 'prod:')3],
The last step is to edit your
.env file and add some references to your staging queues. You'll need to define a
REDIS_QUEUE key/value pair as well as some other key/value pairs for Redis.
That should be all you need to separate your Laravel Horizon instances on the same server.