From 12b2b0fe482ce420bf4c175f5e5d9a6597a69b5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Wed, 19 Apr 2023 15:05:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HotReload.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/HotReload.php b/HotReload.php index 233c1dc..79cb776 100644 --- a/HotReload.php +++ b/HotReload.php @@ -128,6 +128,12 @@ class HotReload extends Command $this->watch($init, $dir); } Event::add($init, fn() => $this->check($init)); + Event::cycle(function () use ($init) { + $pid = (int)file_get_contents(storage('.swoole.pid')); + if ($pid <= 0 || !Process::kill($pid, 0)) { + Event::del($init); + } + }, true); Event::wait(); }