Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.x] Add commands to pause and continue supervisors #914

Merged
merged 2 commits into from
Oct 23, 2020
Merged

[5.x] Add commands to pause and continue supervisors #914

merged 2 commits into from
Oct 23, 2020

Conversation

paras-malhotra
Copy link
Contributor

@paras-malhotra paras-malhotra commented Oct 23, 2020

Currently, it is possible to pause and continue the master supervisor. But there is no command readily available to pause and continue specific supervisors. This could be a common use case in production.

For instance, say we want to pause a supervisor that runs a dedicated queue for unstable APIs. If the API is currently unavailable, pausing that specific supervisor really helps so that the jobs are queued up and can be continued (without exhausting their tries) once the API is up and running.

Screenshot 2020-10-23 at 3 48 15 PM

EDIT: I've added separate commands instead of modifying existing PauseCommand and ContinueCommand (used for master supervisor) so that there's no breaking change and this PR can be included for 5x.

@paras-malhotra
Copy link
Contributor Author

paras-malhotra commented Oct 23, 2020

I've slightly modified the PR so that both full and short names of supervisor work. E.g. both of the below commands work:

php artisan horizon:pause-supervisor paras-macbook-prolocal-cEEq:supervisor-1 and
php artisan horizon:pause-supervisor supervisor-1

The second one is the same name as appears in the horizon.php config file and the first one is the full name of the supervisor as appears in the horizon:supervisors command.

@taylorotwell taylorotwell merged commit c09d784 into laravel:5.x Oct 23, 2020
@paras-malhotra paras-malhotra deleted the pause_supervisors branch October 23, 2020 13:52
Copy link
Contributor

@mfn mfn left a comment

Choose a reason for hiding this comment

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

Very nice, just a suggestion regarding the wording!

$this->info("Sending CONT Signal To Process: {$processId}");

if (! posix_kill($processId, SIGCONT)) {
$this->error("Failed to kill process: {$processId} (".posix_strerror(posix_get_last_error()).')');
Copy link
Contributor

Choose a reason for hiding this comment

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

Failed to kill process

Just a small feedback that this is not what's happening from the user perspective: we're not trying to send SIGKILL or SIGTERM here, maybe it should be rephrased to "Cant send signal SIGCONT to…" or so?

$this->info("Sending USR2 Signal To Process: {$processId}");

if (! posix_kill($processId, SIGUSR2)) {
$this->error("Failed to kill process: {$processId} (".posix_strerror(posix_get_last_error()).')');
Copy link
Contributor

Choose a reason for hiding this comment

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

Failed to kill process

Basically the same feedback, something like "Cant send signal SIGUSR2 to…" 🤔

@driesvints
Copy link
Member

@mfn can you send in a PR for those?

@paras-malhotra
Copy link
Contributor Author

paras-malhotra commented Oct 27, 2020

@mfn, this resembles the pause/continue commands for the master supervisor. It stems from a funny unix history, where the unix kill command is used to send any signal, not just SIGKILL. This nomenclature trickled down to php with posix_kill. If you wish to send a PR to make it obvious, you can also change the PauseCommand and ContinueCommand accordingly.

taylorotwell pushed a commit that referenced this pull request Oct 30, 2020
@driesvints
Copy link
Member

@paras-malhotra can you maybe PR these new commands to the docs?

@paras-malhotra
Copy link
Contributor Author

@driesvints sent a PR to the docs: laravel/docs#6544

@driesvints
Copy link
Member

@paras-malhotra thanks! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants