Skip to content

Commit 729ed24

Browse files
[12.x] Add documentation for worker restart and pause signals (#10936)
* Update queues.md * Update queues.md * Update queues.md * too much info * anchor * formatting * formatting --------- Co-authored-by: Taylor Otwell <taylor@laravel.com>
1 parent f436cac commit 729ed24

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

queues.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2313,6 +2313,43 @@ php artisan queue:continue database:default
23132313

23142314
After resuming a queue, workers will begin processing new jobs from that queue immediately. Note that pausing a queue does not stop the worker process itself - it only prevents the worker from processing new jobs from the specified queue.
23152315

2316+
<a name="worker-restart-and-pause-signals"></a>
2317+
#### Worker Restart and Pause Signals
2318+
2319+
By default, queue workers poll the cache driver for restart and pause signals on each job iteration. While this polling is essential for responding to `queue:restart` and `queue:pause` commands, it does introduce a small performance overhead.
2320+
2321+
If you need to optimize performance and don't require these interruption features, you may disable this polling globally by calling the `withoutInterruptionPolling` method on the `Queue` facade. This should typically be done in the `boot` method of your `AppServiceProvider`:
2322+
2323+
```php
2324+
use Illuminate\Support\Facades\Queue;
2325+
2326+
/**
2327+
* Bootstrap any application services.
2328+
*/
2329+
public function boot(): void
2330+
{
2331+
Queue::withoutInterruptionPolling();
2332+
}
2333+
```
2334+
2335+
Alternatively, you may disable restart or pause polling individually by setting the static `$restartable` or `$pausable` properties on the `Illuminate\Queue\Worker` class:
2336+
2337+
```php
2338+
use Illuminate\Queue\Worker;
2339+
2340+
/**
2341+
* Bootstrap any application services.
2342+
*/
2343+
public function boot(): void
2344+
{
2345+
Worker::$restartable = false;
2346+
Worker::$pausable = false;
2347+
}
2348+
```
2349+
2350+
> [!WARNING]
2351+
> When interruption polling is disabled, workers will not respond to `queue:restart` or `queue:pause` commands (depending on which features are disabled).
2352+
23162353
<a name="supervisor-configuration"></a>
23172354
## Supervisor Configuration
23182355

0 commit comments

Comments
 (0)