From ea09d3e3baf307d85980e80568db28d295929f20 Mon Sep 17 00:00:00 2001 From: Administrator Date: Fri, 19 Nov 2021 03:36:35 +0800 Subject: [PATCH] 1 --- kiri-engine/FileListen/HotReload.php | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/kiri-engine/FileListen/HotReload.php b/kiri-engine/FileListen/HotReload.php index 877c6832..18ff81ea 100644 --- a/kiri-engine/FileListen/HotReload.php +++ b/kiri-engine/FileListen/HotReload.php @@ -83,7 +83,6 @@ class HotReload extends Command } - /** * @throws Exception */ @@ -149,7 +148,6 @@ class HotReload extends Command } - /** * 重启 * @@ -158,18 +156,14 @@ class HotReload extends Command public function trigger_reload() { Kiri::getDi()->get(Logger::class)->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); + $pid = file_get_contents(storage('.swoole.pid')); + if (!empty($pid) && Process::kill($pid, 0)) { + Process::kill($pid, SIGTERM); Process::wait(TRUE); } - $this->process = new Process(function (Process $process) { - $process->exec(PHP_BINARY, [APP_PATH . "kiri.php", "sw:server", "restart"]); - },null,null,FALSE); - $this->process->start(); + Coroutine::create(function () { + proc_open('php ' . APP_PATH . ' kiri.php sw:server restart', [], $pipes); + }); }