Laravel horizon - how to change worker sleep config?

When running the workers directly in Laravel, we can use the following command to config how long we want the worker to sleep if there is no job to be processed in the queue.

php artisan queue:work --sleep=3

How do I config this option when I am using Laravel Horizon to manage my workers?


Solution 1:

Go to config/horizon.php

You have an array with the possible env, right?

You can add sleep for each env:

'environments' => [
'production' => [
    'supervisor-default' => [
        'connection' => 'redis',
        'queue' => ['default'],
        'balance' => false,
        'processes' => 30,
        'tries' => 3,
        'sleep' => 3
        ]
    ]
]