Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Messenger] Messenger: add--duration option tomessenger:stop-workers command#60517

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
dwalck wants to merge7 commits intosymfony:7.4
base:7.4
Choose a base branch
Loading
fromdwalck:feature/messenger-stop-workers-duration

Conversation

dwalck
Copy link

@dwalckdwalck commentedMay 22, 2025
edited
Loading

QA
Branch?7.4
Bug fix?no
New feature?yes
Deprecations?no
LicenseMIT

Hi!

My proposal is to add a--duration option to themessenger:stop-workers command, which would allow to "pause" the workers for the amount of time specified in this option.

For example, if we pass--duration=10, then for the next 10 seconds, runningmessenger:consume will return a message indicating how many seconds are left until the "pause" ends.

I think this option would be helpful during deployments (we're using it this way in my company).

image

image

@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has acontribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (seehttps://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (seehttps://symfony.com/releases)
  • Features and deprecations must be submitted against the 7.3 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@carsonbotcarsonbot changed the titleMessenger: add --duration option to messenger:stop-workers command[Messenger] Messenger: add --duration option to messenger:stop-workers commandMay 23, 2025
@OskarStark
Copy link
Contributor

Please add a line in the changelog. Please use 7.4 there, as 7.3 is already in feature freeze 🥶

It looks that your committer email is not associated with your GitHub account, you might want to check this.

@dwalckdwalckforce-pushed thefeature/messenger-stop-workers-duration branch 2 times, most recently from3c603a7 to779fcb2CompareMay 23, 2025 06:19
7.4
---

* Add`--duration` option to`messenger:stop-workers` command to keep workers in paused state.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
* Add`--duration` option to`messenger:stop-workers` command to keep workers in paused state.
* Add`--duration` option to`messenger:stop-workers` command to keep workers in paused state

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Done :)

@OskarStarkOskarStark changed the title[Messenger] Messenger: add --duration option to messenger:stop-workers command[Messenger] Messenger: add--duration option tomessenger:stop-workers commandMay 23, 2025
@dwalckdwalckforce-pushed thefeature/messenger-stop-workers-duration branch fromc906cdc tob604d41CompareMay 25, 2025 16:50
@dwalckdwalckforce-pushed thefeature/messenger-stop-workers-duration branch fromb604d41 to60b0c31CompareMay 25, 2025 17:18
@fabpotfabpot modified the milestones:7.3,7.4May 26, 2025
@@ -44,6 +48,11 @@ protected function configure(): void
Each worker command will finish the message they are currently processing
and then exit. Worker commands are *not* automatically restarted: that
should be handled by a process control system.
Use the --duration option to keep the workers in a paused state (not processing messages) for the given duration (in seconds).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
Usethe --duration option to keep the workers in a paused state (not processing messages) for the given duration (in seconds).
Use the<comment>--duration</comment> option to keep the workers in a paused state (not processing messages)for the given duration (in seconds).

@@ -35,7 +37,9 @@ public function __construct(
protectedfunctionconfigure():void
{
$this
->setDefinition([])
->setDefinition([
newInputOption('duration','d', InputOption::VALUE_REQUIRED,'Duration in seconds to keep the workers stopped'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
newInputOption('duration','d', InputOption::VALUE_REQUIRED,'Duration in secondsto keep theworkersstopped'),
newInputOption('duration','d', InputOption::VALUE_REQUIRED,'Duration in secondsduring whichworkersare paused (not processing messages)'),

$this->restartSignalCachePool->save($cacheItem);

$io->success('Signal successfully sent to stop any running workers.');
if ($duration >0) {
$io->info(sprintf('Workers will be stopped for next %s seconds.',$duration));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
$io->info(sprintf('Workers will bestopped for next %s seconds.',$duration));
$io->info(sprintf('Workers will bepaused for %s seconds.',$duration));

if ($this->shouldRestart()) {
$event->getWorker()->stop();
$remainingStopSeconds =ceil($this->getEndOfStopTime()) -time();
$this->logger?->info(sprintf('Worker is stopped and message processing is paused for the next %d seconds.',$remainingStopSeconds));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
$this->logger?->info(sprintf('Workerisstopped and message processingis paused for the next %d seconds.',$remainingStopSeconds));
$this->logger?->info(sprintf('The workerispaused and message processingwill resume in %d seconds.',$remainingStopSeconds));

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@alexandre-dauboisalexandre-dauboisalexandre-daubois left review comments

@fabpotfabpotfabpot requested changes

Assignees
No one assigned
Projects
None yet
Milestone
7.4
Development

Successfully merging this pull request may close these issues.

5 participants
@dwalck@carsonbot@OskarStark@fabpot@alexandre-daubois

[8]ページ先頭

©2009-2025 Movatter.jp