qqq
This commit is contained in:
+17
-37
@@ -6,6 +6,7 @@ namespace Kiri\Server;
|
||||
use Exception;
|
||||
use Kiri\Di\Context;
|
||||
use Kiri\Server\Abstracts\BaseProcess;
|
||||
use ReflectionException;
|
||||
use Swoole\Coroutine;
|
||||
use Swoole\Event;
|
||||
use Swoole\Process;
|
||||
@@ -48,48 +49,27 @@ class HotReload extends BaseProcess
|
||||
if (Context::inCoroutine()) {
|
||||
Coroutine::create(fn() => $this->onShutdown(Coroutine::waitSignal(SIGTERM | SIGINT)));
|
||||
} else {
|
||||
Process::signal(SIGTERM, function ($data) {
|
||||
|
||||
var_dump('收到消息');
|
||||
|
||||
foreach ($this->watchFiles as $file) {
|
||||
@inotify_rm_watch($file, $this->inotify);
|
||||
}
|
||||
$this->onShutdown($data);
|
||||
});
|
||||
Process::signal(SIGINT, function ($data) {
|
||||
|
||||
var_dump('收到消息');
|
||||
|
||||
foreach ($this->watchFiles as $file) {
|
||||
@inotify_rm_watch($file, $this->inotify);
|
||||
}
|
||||
$this->onShutdown($data);
|
||||
});
|
||||
|
||||
pcntl_signal(SIGTERM, function ($data) {
|
||||
|
||||
var_dump('收到消息');
|
||||
|
||||
foreach ($this->watchFiles as $file) {
|
||||
@inotify_rm_watch($file, $this->inotify);
|
||||
}
|
||||
$this->onShutdown($data);
|
||||
});
|
||||
pcntl_signal(SIGINT, function ($data) {
|
||||
|
||||
var_dump('收到消息');
|
||||
|
||||
foreach ($this->watchFiles as $file) {
|
||||
@inotify_rm_watch($file, $this->inotify);
|
||||
}
|
||||
$this->onShutdown($data);
|
||||
});
|
||||
pcntl_signal(SIGTERM, [$this, 'onStop']);
|
||||
pcntl_signal(SIGINT, [$this, 'onStop']);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @return void
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function onStop($data): void
|
||||
{
|
||||
foreach ($this->watchFiles as $file) {
|
||||
@inotify_rm_watch($file, $this->inotify);
|
||||
}
|
||||
$this->onShutdown($data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Process|null $process
|
||||
* @return void
|
||||
|
||||
Reference in New Issue
Block a user