diff --git a/kiri-engine/FileListen/FileChangeCustomProcess.php b/kiri-engine/FileListen/FileChangeCustomProcess.php index c1ec667d..1a7b67fb 100644 --- a/kiri-engine/FileListen/FileChangeCustomProcess.php +++ b/kiri-engine/FileListen/FileChangeCustomProcess.php @@ -30,6 +30,9 @@ class FileChangeCustomProcess extends Command public int $int = -1; + protected mixed $source; + + /** * */ @@ -60,10 +63,17 @@ class FileChangeCustomProcess extends Command $driver = Kiri::getDi()->get(Inotify::class, [$this->dirs, $this]); } $make = Barrier::make(); + go(function () { + $this->trigger_reload(); + }); go(function () { $sign = Coroutine::waitSignal(SIGTERM, -1); if ($sign) { - proc_open("php " . APP_PATH . "kiri.php sw:server stop", [], $pipes); + if ($this->source) { + proc_close($this->source); + } + $this->source = proc_open("php " . APP_PATH . "kiri.php sw:server stop", [], $pipes); + proc_close($this->source); } }); go(function () use ($driver) { @@ -97,7 +107,9 @@ class FileChangeCustomProcess extends Command public function trigger_reload() { Kiri::getDi()->get(Logger::class)->warning('change reload'); - - proc_open("php " . APP_PATH . "kiri.php sw:server restart", [], $pipes); + if ($this->source) { + proc_close($this->source); + } + $this->source = proc_open("php " . APP_PATH . "kiri.php sw:server restart", [], $pipes); } } diff --git a/kiri-engine/FileListen/Inotify.php b/kiri-engine/FileListen/Inotify.php index 6eea8467..785a3bdc 100644 --- a/kiri-engine/FileListen/Inotify.php +++ b/kiri-engine/FileListen/Inotify.php @@ -30,8 +30,6 @@ class Inotify */ public function start() { - $this->process->trigger_reload(); - $this->inotify = inotify_init(); $this->events = IN_MODIFY | IN_DELETE | IN_CREATE | IN_MOVE; foreach ($this->dirs as $dir) {