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