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

Implement Limiting Max Child Processes Via an Exec Env Var API #69

Open
wants to merge 1 commit into
base: 4.x
Choose a base branch
from

Conversation

rhift
Copy link
Contributor

@rhift rhift commented May 7, 2019

  • create Memory singleton
  • move canEnvironmentSustainAdditionProcesses to Strategy
  • use Memory singleton in canEnvironmentSustainAdditionProcesses
  • DI YAML trailing newlines <3 mucha
  • add public access modifier to some constants in StrategyInterface
  • trailing newline in StrategyInterface <3 mucha
  • add apply memory limit using Memory singleton in Job Process class
  • import Throwable in Job Process class
  • inject Memory singleton into Job Process class
  • remove canEnvironmentSustainAdditionProcesses from ProcessInterface
  • add trailing newline to ProcessInterface <3 mucha

* create Memory singleton
* move canEnvironmentSustainAdditionProcesses to Strategy
* use Memory singleton in canEnvironmentSustainAdditionProcesses
* DI YAML trailing newlines <3 mucha
* add public access modifier to some constants in StrategyInterface
* trailing newline in StrategyInterface <3 mucha
* add apply memory limit using Memory singleton in Job Process class
* import Throwable in Job Process class
* inject Memory singleton into Job Process class
* remove canEnvironmentSustainAdditionProcesses from ProcessInterface
* add trailing newline to ProcessInterface <3 mucha
@rhift rhift requested review from alexberryman and mucha55 May 7, 2019 18:44
case self::Mebibyte:
$Value *= 1024;
case self::Kibibyte:
$Value *= 1024;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I should have a default exceptional case here.

@@ -56,6 +59,41 @@ public function setAlarmProcessTypeCode(string $alarmProcessTypeCode): StrategyI
return $this;
}

public function canEnvironmentSustainAdditionalProcesses(): bool
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will be executed for each Strategy (Server, Root, Job, etc). That behavior should be benign, but it's not correct. I need to have the memory condition be specific to a strategy. I'll fix it but it shouldn't have bearing on public behavior.

{
$processMaximumMemoryValue = $this->getEnvironmentMemory()->getWorkerMaximumMemoryValue();
$this->_getLogger()->debug(sprintf('Applying memory limit of [%s] bytes.', $processMaximumMemoryValue));
ini_set('memory_limit', $processMaximumMemoryValue);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that PHP will set memory_limit to be 2MiB if it is set to any smaller value. 2MiB is the smallest PHP allows.

@@ -0,0 +1,15 @@
parameters:
Neighborhoods\Kojo\Environment\MemoryInterface.EnvironmentMaximumMemoryInputValue: '%env(ENVIRONMENT_MAXIMUM_MEMORY_INPUT_VALUE)%'
Copy link
Contributor

Choose a reason for hiding this comment

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

Allows missing values since this will be a 4.x release.
Fatal error: Uncaught Symfony\Component\DependencyInjection\Exception\EnvNotFoundException: Environment variable not found: "ENVIRONMENT_MAXIMUM_MEMORY_INPUT_VALUE". in /var/www/html/kojo_fitness.neighborhoods.com/UseCase46/vendor/symfony/dependency-injection/EnvVarProcessor.php on line 131

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.

2 participants