From 49d435e4a524f55b885f3de3192e7006aebe3a53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Thu, 4 Nov 2021 18:36:17 +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/FileChangeCustomProcess.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/kiri-engine/FileListen/FileChangeCustomProcess.php b/kiri-engine/FileListen/FileChangeCustomProcess.php index dbc97b2d..a30abbe2 100644 --- a/kiri-engine/FileListen/FileChangeCustomProcess.php +++ b/kiri-engine/FileListen/FileChangeCustomProcess.php @@ -9,6 +9,7 @@ use Kiri\Exception\ConfigException; use Kiri\Kiri; use Swoole\Coroutine; use Swoole\Coroutine\Barrier; +use Swoole\Process; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -80,7 +81,6 @@ class FileChangeCustomProcess extends Command } - /** * @param $code * @param $message @@ -104,9 +104,14 @@ class FileChangeCustomProcess extends Command public function trigger_reload($cid) { Kiri::getDi()->get(Logger::class)->warning('change reload'); - if (is_resource($this->source)) { + + $content = file_get_contents(storage('.swoole.pid')); + + if (!empty($content)) { + Process::kill(storage('.swoole.pid'), 15); proc_close($this->source); } + $this->source = proc_open("php " . APP_PATH . "kiri.php sw:server restart", [], $this->pipes); }