8000 [FrameworkBundle] Make StopWorkerOnSignalsListener configurable via m… · symfony/symfony@245d75d · GitHub
[go: up one dir, main page]

Skip to content

Commit 245d75d

Browse files
Rokas Mikalkėnasnicolas-grekas
Rokas Mikalkėnas
authored andcommitted
[FrameworkBundle] Make StopWorkerOnSignalsListener configurable via messenger's config
1 parent a08ccfc commit 245d75d

File tree

4 files changed

+11
-0
lines changed

4 files changed

+11
-0
lines changed

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ CHANGELOG
2020
* Add `AbstractController::sendEarlyHints()` to send HTTP Early Hints
2121
* Add autowiring aliases for `Http\Client\HttpAsyncClient`
2222
* Deprecate the `Http\Client\HttpClient` service, use `Psr\Http\Client\ClientInterface` instead
23+
* Add `stop_worker_on_signals` configuration option to `messenger` to define signals which would stop a worker
2324

2425
6.2
2526
---

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

+5
Original file line numberDiff line numberDiff line change
@@ -1528,6 +1528,11 @@ function ($a) {
15281528
->thenInvalid('The "framework.messenger.reset_on_message" configuration option can be set to "true" only. To prevent services resetting after each message you can set the "--no-reset" option in "messenger:consume" command.')
15291529
->end()
15301530
->end()
1531+
->arrayNode('stop_worker_on_signals')
1532+
->defaultValue([])
1533+
->info('A list of signals that should stop the worker; defaults to SIGTERM and SIGINT.')
1534+
->integerPrototype()->end()
1535+
->end()
15311536
->scalarNode('default_bus')->defaultNull()->end()
15321537
->arrayNode('buses')
15331538
->defaultValue(['messenger.bus.default' => ['default_middleware' => ['enabled' => true, 'allow_no_handlers' => false, 'allow_no_senders' => true], 'middleware' => []]])

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

+4
Original file line numberDiff line numberDiff line change
@@ -2050,6 +2050,10 @@ private function registerMessengerConfiguration(array $config, ContainerBuilder
20502050
$container->getDefinition('messenger.transport.beanstalkd.factory')->addTag('messenger.transport_factory');
20512051
}
20522052

2053+
if ($config['stop_worker_on_signals']) {
2054+
$container->getDefinition('messenger.listener.stop_worker_signals_listener')->replaceArgument(0, $config['stop_worker_on_signals']);
2055+
}
2056+
20532057
if (null === $config['default_bus'] && 1 === \count($config['buses'])) {
20542058
$config['default_bus'] = key($config['buses']);
20552059
}

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,7 @@ class_exists(SemaphoreStore::class) && SemaphoreStore::isSupported() ? 'semaphor
639639
'default_bus' => null,
640640
'buses' => ['messenger.bus.default' => ['default_middleware' => ['enabled' => true, 'allow_no_handlers' => false, 'allow_no_senders' => true], 'middleware' => []]],
641641
'reset_on_message' => true,
642+
'stop_worker_on_signals' => [],
642643
],
643644
'disallow_search_engine_index' => true,
644645
'http_client' => [

0 commit comments

Comments
 (0)
0