From 587288ab9f045413ed3a43ceaceac0382e9e2a55 Mon Sep 17 00:00:00 2001 From: Hamid Alaei Varnosfaderani Date: Tue, 16 Mar 2021 16:12:07 +0330 Subject: [PATCH] Fix checking parent id (#989) --- src/QueueCommandString.php | 3 ++- src/SupervisorOptions.php | 3 ++- tests/Feature/AddSupervisorTest.php | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/QueueCommandString.php b/src/QueueCommandString.php index ea34cf2b..be03d3ec 100644 --- a/src/QueueCommandString.php +++ b/src/QueueCommandString.php @@ -27,7 +27,7 @@ public static function toWorkerOptionsString(SupervisorOptions $options) */ public static function toSupervisorOptionsString(SupervisorOptions $options) { - return sprintf('--workers-name=%s --balance=%s --max-processes=%s --min-processes=%s --nice=%s --balance-cooldown=%s --balance-max-shift=%s %s', + return sprintf('--workers-name=%s --balance=%s --max-processes=%s --min-processes=%s --nice=%s --balance-cooldown=%s --balance-max-shift=%s --parent-id=%s %s', $options->workersName, $options->balance, $options->maxProcesses, @@ -35,6 +35,7 @@ public static function toSupervisorOptionsString(SupervisorOptions $options) $options->nice, $options->balanceCooldown, $options->balanceMaxShift, + $options->parentId, static::toOptionsString($options) ); } diff --git a/src/SupervisorOptions.php b/src/SupervisorOptions.php index 39613381..fc276d03 100644 --- a/src/SupervisorOptions.php +++ b/src/SupervisorOptions.php @@ -205,7 +205,7 @@ public function __construct($name, $this->nice = $nice; $this->balanceCooldown = $balanceCooldown; $this->balanceMaxShift = $balanceMaxShift; - $this->parentId = 0; + $this->parentId = $parentId; } /** @@ -297,6 +297,7 @@ public function toArray() 'timeout' => $this->timeout, 'balanceCooldown' => $this->balanceCooldown, 'balanceMaxShift' => $this->balanceMaxShift, + 'parentId' => $this->parentId, ]; } diff --git a/tests/Feature/AddSupervisorTest.php b/tests/Feature/AddSupervisorTest.php index f5cce2b2..9f1431e6 100644 --- a/tests/Feature/AddSupervisorTest.php +++ b/tests/Feature/AddSupervisorTest.php @@ -28,7 +28,7 @@ public function test_add_supervisor_command_creates_new_supervisor_on_master_pro $this->assertCount(1, $master->supervisors); $this->assertSame( - 'exec '.$phpBinary.' artisan horizon:supervisor my-supervisor redis --workers-name=default --balance=off --max-processes=1 --min-processes=1 --nice=0 --balance-cooldown=3 --balance-max-shift=1 --backoff=0 --max-time=0 --max-jobs=0 --memory=128 --queue="default" --sleep=3 --timeout=60 --tries=0', + 'exec '.$phpBinary.' artisan horizon:supervisor my-supervisor redis --workers-name=default --balance=off --max-processes=1 --min-processes=1 --nice=0 --balance-cooldown=3 --balance-max-shift=1 --parent-id=0 --backoff=0 --max-time=0 --max-jobs=0 --memory=128 --queue="default" --sleep=3 --timeout=60 --tries=0', $master->supervisors->first()->process->getCommandLine() ); }