This commit is contained in:
xl
2024-09-04 10:14:30 +08:00
parent f4a5a4dbee
commit 524d2b8664
+5 -12
View File
@@ -5,6 +5,7 @@ namespace Kiri\Rpc;
use Kiri\Di\Context; use Kiri\Di\Context;
use Kiri\Server\Processes\AbstractProcess; use Kiri\Server\Processes\AbstractProcess;
use Swoole\Coroutine; use Swoole\Coroutine;
use Swoole\Process;
use function pcntl_signal; use function pcntl_signal;
class RpcProcess extends AbstractProcess class RpcProcess extends AbstractProcess
@@ -21,27 +22,19 @@ class RpcProcess extends AbstractProcess
/** /**
* @param \Swoole\Process|null $process * @param Process|null $process
* @return void * @return void
*/ */
public function process(?\Swoole\Process $process): void public function process(?Process $process): void
{ {
} }
/** /**
* @return $this * @return void
*/ */
public function onSigterm(): static public function onSigterm(): void
{ {
// TODO: Implement onSigterm() method.
if (Context::inCoroutine()) {
Coroutine::create(fn() => $this->onShutdown(Coroutine::waitSignal(SIGTERM | SIGINT)));
} else {
pcntl_signal(SIGTERM, [$this, 'onStop']);
pcntl_signal(SIGINT, [$this, 'onStop']);
}
return $this;
} }
} }