diff --git a/src/AutoScaler.php b/src/AutoScaler.php index b8c5e35a..c597a9db 100644 --- a/src/AutoScaler.php +++ b/src/AutoScaler.php @@ -147,10 +147,14 @@ protected function scalePool(Supervisor $supervisor, $pool, $workers) { $supervisor->pruneTerminatingProcesses(); - $totalProcessCount = $pool->totalProcessCount(); + $totalProcessCount = $pool->processes()->count(); $desiredProcessCount = ceil($workers); + if ($desiredProcessCount > $totalProcessCount) { + $totalProcessCount = $pool->totalProcessCount(); + } + if ($desiredProcessCount > $totalProcessCount) { $maxUpShift = min( max(0, $supervisor->options->maxProcesses - $supervisor->totalProcessCount()), diff --git a/tests/Feature/Fakes/FakePool.php b/tests/Feature/Fakes/FakePool.php index 5ed7482d..051eed1d 100644 --- a/tests/Feature/Fakes/FakePool.php +++ b/tests/Feature/Fakes/FakePool.php @@ -32,4 +32,9 @@ public function totalProcessCount() { return $this->processCount; } + + public function processes() + { + return collect(range(1, $this->processCount)); + } }