From a8557653651edc44618ea4783aec874b56576ca2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Fri, 19 Nov 2021 18:13:48 +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 | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/kiri-engine/FileListen/HotReload.php b/kiri-engine/FileListen/HotReload.php index 2ba78ee1..56941a54 100644 --- a/kiri-engine/FileListen/HotReload.php +++ b/kiri-engine/FileListen/HotReload.php @@ -138,17 +138,15 @@ class HotReload extends Command public function trigger_reload() { $this->logger->warning('change reload'); -// $pid = file_get_contents(storage('.swoole.pid')); -// if (!empty($pid) && Process::kill($pid, 0)) { -// Process::kill($pid, SIGTERM); -// } - if ($this->process && Process::kill($this->process->pid, 0)) { - Process::kill($this->process->pid) && Process::wait(true); - } - $this->process = new Process(function (Process $process) { + $pid = $this->process->pid; + $process = new Process(function (Process $process) { $process->exec(PHP_BINARY, [APP_PATH . "kiri.php", "sw:server", "restart"]); }); - $this->process->start(); + $process->start(); + if ($pid && Process::kill($pid, 0)) { + Process::kill($pid) && Process::wait(true); + } + $this->process = $process; }