This commit is contained in:
xl
2024-09-03 14:47:29 +08:00
parent 6418b3288b
commit af613784fd
+4 -3
View File
@@ -3,9 +3,10 @@
namespace Kiri\Rpc; namespace Kiri\Rpc;
use Kiri\Di\Context; use Kiri\Di\Context;
use Kiri\Server\Abstracts\BaseProcess; use Kiri\Server\Processes\BaseProcess;
use Swoole\Coroutine; use Swoole\Coroutine;
use Swoole\Process; use Swoole\Process;
use function pcntl_signal;
class RpcProcess extends BaseProcess class RpcProcess extends BaseProcess
{ {
@@ -39,8 +40,8 @@ class RpcProcess 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 {
\pcntl_signal(SIGTERM, [$this, 'onStop']); pcntl_signal(SIGTERM, [$this, 'onStop']);
\pcntl_signal(SIGINT, [$this, 'onStop']); pcntl_signal(SIGINT, [$this, 'onStop']);
} }
return $this; return $this;
} }