Repository navigation
Add restart signal listener to restart workers after a deployment - #59
Merged
Merged
Conversation
DanielBadura
approved these changes
Oct 4, 2026
StopWorkerOnRestartSignalListener stops the worker once a given file is touched after the worker has started. Touching the file during a deployment makes all running workers restart with the new code. It can be enabled with the new restartSignalFile option in create().
The start time now comes from the PSR-20 clock, which makes the check for a file touched in the same second as the start deterministic in tests. The stat cache test changes the file from another process, since touching it from within the test process clears the cache anyway.
DavidBadura
force-pushed
the
restart-signal-listener
branch
from
October 5, 2026 07:22
d480d6f to
56e81fb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Long-running workers keep the code they were started with, so after a deployment they have to be restarted somehow. This adds a StopWorkerOnRestartSignalListener, similar to messenger:stop-workers in Symfony: it remembers when the worker started and stops it once a given file has been modified after that. Running
touch var/worker-restartin the deployment is enough, the file can stay in place for the next one. It can be enabled through the new restartSignalFile option in create().The modification time is only checked after each iteration, and the stat cache is cleared before every check, otherwise PHP would keep returning the old filemtime. Since filemtime has second precision, a touch in the same second the worker started is ignored, which should be fine as that worker already runs the new code.
The custom listener example in the events docs was a "new deployment" listener, which is now built in, so I replaced it with a maintenance mode example.