feat: implement ConsoleCommandListener #42
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request refactors the handling of OS signals for daemon commands by introducing a dedicated
ConsoleCommandListenerthat responds to Symfony'sConsoleSignalEvent. The signal handling logic is moved out ofDaemonCommand, and comprehensive unit and integration tests are added to ensure correct behavior. The documentation is also updated to describe the new testing strategy and best practices.Event-driven signal handling and listener introduction:
ConsoleCommandListenerclass that listens forConsoleSignalEventand triggers shutdown onDaemonCommandinstances when receiving SIGTERM or SIGINT, using Symfony's event system and PHP 8 attributes. (src/EventListener/ConsoleCommandListener.php)handleSignalmethod and related signal handler registration fromDaemonCommand, making signal handling fully event-driven. (src/Command/DaemonCommand.php) [1] [2]Testing improvements:
tests/Unit/EventListener/ConsoleCommandListenerTest.php)tests/Integration/EventListener/ConsoleCommandListenerIntegrationTest.php)DaemonCommandConcreteto include anisShutdownRequested()helper for easier assertions in tests. (tests/Fixtures/Command/DaemonCommandConcrete.php)DaemonCommandTest. (tests/Unit/Command/DaemonCommandTest.php)Documentation updates:
docs/CONSOLE_COMMAND_LISTENER_TESTS.md)