[12.x] feat: Add WorkerStarting event when worker daemon starts #55941
+70
−4
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.
Creates a new
WorkerStarting
event that fires just as a new worker daemon starts.This provides an excellent hook point to perform actions just as a worker starts, instead of having to rely on handling things before processing individual jobs.
I have personally encountered the need to apply extra setup as a worker starts. Without this, I have needed to execute certain setup before each job starts with
JobProcessing
.Although the core of the change is backward compatible, I added a
starting
method tosrc/Illuminate/Queue/QueueManager.php
and thesrc/Illuminate/Contracts/Queue/Monitor.php
interface. Which I can revert if it is determined that the changing of an interface is not wanted at this time.