From 6ac2c73a8c385f85c46ee3304a80018aedbacff3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Fri, 19 Nov 2021 10:31:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kiri-engine/FileListen/HotReload.php | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/kiri-engine/FileListen/HotReload.php b/kiri-engine/FileListen/HotReload.php index b389ab32..c6307a8a 100644 --- a/kiri-engine/FileListen/HotReload.php +++ b/kiri-engine/FileListen/HotReload.php @@ -132,19 +132,17 @@ class HotReload extends Command public function trigger_reload() { $this->logger->warning('change reload'); - if ($this->process instanceof Process && Process::kill($this->process->pid, 0)) { - $pid = file_get_contents(storage('.swoole.pid')); - if (!empty($pid) && Process::kill($pid, 0)) { - Process::kill($pid, SIGTERM); - } -// Process::kill($this->process->pid, SIGTERM); - $this->process->exit(0); - Process::wait(true); + $pid = file_get_contents(storage('.swoole.pid')); + if (!empty($pid) && Process::kill($pid, 0)) { + Process::kill($pid, SIGTERM); + } + Process::wait(true); + if (!$this->process) { + $this->process = new Process(function (Process $process) { + $process->exec(PHP_BINARY, [APP_PATH . "kiri.php", "sw:server", "restart"]); + }); + $this->process->start(); } - $this->process = new Process(function (Process $process) { - $process->exec(PHP_BINARY, [APP_PATH . "kiri.php", "sw:server", "restart"]); - }); - $this->process->start(); }