This commit is contained in:
2021-11-04 18:02:33 +08:00
parent 38f5f57c4d
commit 043b62688b
2 changed files with 15 additions and 5 deletions
@@ -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);
}
}
-2
View File
@@ -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) {