Skip to content

Commit

Permalink
Merge pull request #99 from neighborhoods/KOJO-180-clean-up-root-proc…
Browse files Browse the repository at this point in the history
…ess-pool-after-jsclp-exit

KOJO-180 | Clean up Root's Process Pool after JSCLP exit
  • Loading branch information
mucha55 committed Jan 22, 2020
2 parents 1b5056b + 28a5864 commit 42a3e69
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/Process/Pool/Strategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function childProcessExited(ProcessInterface $process): StrategyInterface
} elseif ($process instanceof ListenerInterface) {
$this->_listenerProcessExited($process);
} elseif ($process instanceof JobStateChangelogProcessorInterface) {
// A new STL process will be created by the Root when appropriate
$this->_jobStateChangelogProcessorProcessExited($process);
} else {
$className = get_class($process);
throw new \UnexpectedValueException("Unexpected process class[$className].");
Expand Down Expand Up @@ -98,6 +98,20 @@ protected function _jobProcessExited(JobInterface $jobProcess): Strategy
return $this;
}

protected function _jobStateChangelogProcessorProcessExited(JobStateChangelogProcessorInterface $jsclpProcess) : Strategy
{
$this->_getProcessPool()->freeChildProcess($jsclpProcess->getProcessId());

// usually this is where we'd spawn a new JSCLP to take the place of the one that exited, but
// that is handled by \Neighborhoods\Kojo\Process\Root::pollSingletonProcesses()

if (!$this->_getProcessPool()->hasAlarm()) {
$this->_getProcessPool()->setAlarm($this->getMaxAlarmTime());
}

return $this;
}

public function receivedAlarm(): StrategyInterface
{
if (!$this->_getProcessPool()->isFull() && $this->_getProcessPool()->canEnvironmentSustainAdditionProcesses()) {
Expand Down

0 comments on commit 42a3e69

Please sign in to comment.