-
Notifications
You must be signed in to change notification settings - Fork 645
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
[3.0] Supervisor nice option #551
Conversation
It's backwards compatible because adding constructor arguments with defaults won't break anything. This is fine 👍 |
@halaei Also: always add the full description for this PR to your main comment and not just link to a issue/pull request. |
@driesvints Updated comment |
Reading code, I see a --paused option:
Reading that, I wish there was an option to pause a supervisor "only for a few seconds" before starting to scale for the first time. maybe a |
The PHP documentation states that the |
@taylorotwell It will only work if the process is running as a superuser, otherwise an exception will be raised with this message:
|
Support for Windows does not exist until PHP 7.2. Do we need to do anything in code to account for that, or will that be a documentation solution? |
@browner12 This is an optional feature. If it is not supported on an environment you can simply not use it. |
@browner12 Windows support is lacking in general: #170 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No happy about the 0
default and not allowing negative values!
* | ||
* @var int | ||
*/ | ||
public $nice = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is problematic:
- a niceness of
0
is a valid value - the (linux) default for niceness is usually
10
IMHO the correct way is to use null
here.
src/Console/SupervisorCommand.php
Outdated
@@ -23,6 +23,7 @@ class SupervisorCommand extends Command | |||
{--max-processes=1 : The maximum number of total workers to start} | |||
{--min-processes=1 : The minimum number of workers to assign per queue} | |||
{--memory=128 : The memory limit in megabytes} | |||
{--nice=0 : The process niceness} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0
is not a good value, see my other comment
src/Console/SupervisorCommand.php
Outdated
@@ -74,6 +75,10 @@ public function handle(SupervisorFactory $factory) | |||
*/ | |||
protected function start($supervisor) | |||
{ | |||
if ($supervisor->options->nice > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0
is a valid niceness level- so are negative values
This check, see my other comment, should be !== null
It doesn't matter that e.g. negative values are only allowed for root user rights. Don't outsmart the dev who might have run as root for whatever reason, etc.
@mfn The argument of proc_nice is the amount of increment to the niceness:
|
@mfn zero increment means no increment, so no need for null. About letting user to use negative values, that is fine for me, although I don't feel I should use it or run my workers as sudo or use Windows at all ;) |
Maybe I should change the comments in the code from 'The process niceness' to 'Increment to the process niceness'? |
@halaei thanks for correcting me, you're right! Still, I vote for allowing negative values. It's not your decision how others want to run the code. |
This has now been released in v3.1.0 |
This doesn't seem documented: https://laravel.com/docs/11.x/horizon |
Closing #549
This PR increments process niceness on each supervisor via config:
The supervisor calls
proc_nice(5)
to set niceness:I don't know if you can regard it as backward compatible because of the change in supervisor option constructor. Also not sure if it has to be sent to 3.0 or master.