From 72c3fdad7905cbedfac5802ba5f742912ef45312 Mon Sep 17 00:00:00 2001 From: Hasby Maulana Date: Tue, 21 May 2024 16:51:06 +0700 Subject: [PATCH] Update SupervisorStartCommand.php --- .../Commands/SupervisorStartCommand.php | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/Console/Commands/SupervisorStartCommand.php b/src/Console/Commands/SupervisorStartCommand.php index 18b20c1..32cc9fd 100644 --- a/src/Console/Commands/SupervisorStartCommand.php +++ b/src/Console/Commands/SupervisorStartCommand.php @@ -3,6 +3,7 @@ namespace Tripteki\Supervisor\Console\Commands; use Symfony\Component\Process\Process; +use Symfony\Component\Process\Exception\ProcessSignaledException; class SupervisorStartCommand extends Supervisor { @@ -45,21 +46,24 @@ public function createForegroundProcess() { $supervisor = null; - $this->trap([ SIGINT, SIGTERM, SIGQUIT, ], function () use (&$supervisor) { + try { - if ($supervisor) { + $this->trap([ SIGINT, SIGTERM, SIGQUIT, ], function () use (&$supervisor) { - $supervisor->stop(3, SIGINT); - $supervisor->stop(15, SIGTERM); - } + if ($supervisor) { - $this->supervisor->delete(); - }); + $this->shouldKeepRunning = false; + } - if ($this->supervisor->write()) { + $this->supervisor->delete(); + }); - $supervisor = $this->exec("start", "foreground"); - } + if ($this->supervisor->write()) { + + $supervisor = $this->exec("start", "foreground"); + } + + } catch (ProcessSignaledException $thrower) {} } /**