[13.x] Allow jobs to react to worker signals#59833
Merged
taylorotwell merged 4 commits intolaravel:13.xfrom Apr 24, 2026
Merged
[13.x] Allow jobs to react to worker signals#59833taylorotwell merged 4 commits intolaravel:13.xfrom
taylorotwell merged 4 commits intolaravel:13.xfrom
Conversation
|
Thanks for submitting a PR! Note that draft PRs are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface. Pull requests that are abandoned in draft may be closed due to inactivity. |
|
I just want to say thank you for all the queuing improvements you've made over the past months, we heavily utilize queues and these changes are helping a lot 😄 |
Contributor
Author
|
@rforced Thanks! I usually just think about stuff I'd want and give it a whirl. We use queues heavily for all sorts, so this felt like a gap in my head 👍🏻 |
shaedrich
reviewed
Apr 23, 2026
|
|
||
| interface Interruptible | ||
| { | ||
| public function interrupted(int $signal): void; |
Contributor
There was a problem hiding this comment.
You could make this more specific:
Suggested change
| public function interrupted(int $signal): void; | |
| /** | |
| * @param SIG* $signal | |
| */ | |
| public function interrupted(int $signal): void; |
or
Suggested change
| public function interrupted(int $signal): void; | |
| /** | |
| * @param SIGQUIT|SIGTERM|SIGINT $signal | |
| */ | |
| public function interrupted(int $signal): void; |
Contributor
|
Love it, thanks Jack 🚀 |
ca4e577 to
97a0090
Compare
Member
|
Nice one! |
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.
When a worker retrieves a signal like SIGTERM, you can have a set amount of time before it gets killed.
In managed infrastructure, this is usually 10 seconds to 1 minute. (I can set it)
But, right now, the Job is oblivious its going be killed... so the worker knows, but the job doesnt.
So, I thought it would be nice to be able to react from inside the job, if this does happen.
See a basic example video here (audio on) (I changed the method name since):
Details
Screen.Recording.2026-04-23.at.16.36.21.mov
TLDR is you implement the Interruptible interface on the job, and put your logic in the interrupted method which looks something like:
Details
Granted, this may not be something you want to maintain, or you may see a nicer way of passing the signal in, but I thought I'd give it a go! Could probably use some love, but no drama if you dont dig it.
This may need some additional thought and poking as I'm not super 100% knowledge on the queue logic.