qqq
This commit is contained in:
+9
-10
@@ -50,7 +50,7 @@ class HotReload extends BaseProcess
|
|||||||
Coroutine::create(fn() => $this->onShutdown(Coroutine::waitSignal(SIGTERM | SIGINT)));
|
Coroutine::create(fn() => $this->onShutdown(Coroutine::waitSignal(SIGTERM | SIGINT)));
|
||||||
} else {
|
} else {
|
||||||
pcntl_signal(SIGTERM, [$this, 'onStop']);
|
pcntl_signal(SIGTERM, [$this, 'onStop']);
|
||||||
pcntl_signal(SIGINT, [$this, 'onStop']);
|
// pcntl_signal(SIGINT, [$this, 'onStop']);
|
||||||
}
|
}
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@@ -59,13 +59,14 @@ class HotReload extends BaseProcess
|
|||||||
/**
|
/**
|
||||||
* @param $data
|
* @param $data
|
||||||
* @return void
|
* @return void
|
||||||
* @throws ReflectionException
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function onStop($data): void
|
public function onStop($data): void
|
||||||
{
|
{
|
||||||
foreach ($this->watchFiles as $file) {
|
$this->clearWatch();
|
||||||
@inotify_rm_watch($file, $this->inotify);
|
|
||||||
}
|
Event::del($this->inotify);
|
||||||
|
|
||||||
$this->onShutdown($data);
|
$this->onShutdown($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,6 +84,7 @@ class HotReload extends BaseProcess
|
|||||||
} else {
|
} else {
|
||||||
$this->onCrontabReload();
|
$this->onCrontabReload();
|
||||||
}
|
}
|
||||||
|
$process->exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -111,11 +113,8 @@ class HotReload extends BaseProcess
|
|||||||
$this->watch(rtrim($dir, '/'));
|
$this->watch(rtrim($dir, '/'));
|
||||||
}
|
}
|
||||||
Event::add($this->inotify, fn() => $this->check());
|
Event::add($this->inotify, fn() => $this->check());
|
||||||
Event::cycle(function () {
|
Event::cycle(fn() => function() {
|
||||||
$pid = (int)file_get_contents(storage('.swoole.pid'));
|
Event::dispatch();
|
||||||
if ($pid <= 0 || !Process::kill($pid, 0) || $this->isStop()) {
|
|
||||||
Event::del($this->inotify);
|
|
||||||
}
|
|
||||||
}, true);
|
}, true);
|
||||||
Event::wait();
|
Event::wait();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user