Files
kiri-rpc/RpcProcess.php
T

47 lines
864 B
PHP
Raw Permalink Normal View History

2023-07-31 23:09:00 +08:00
<?php
namespace Kiri\Rpc;
use Kiri\Di\Context;
use Kiri\Server\Abstracts\BaseProcess;
use Swoole\Coroutine;
use Swoole\Process;
class RpcProcess extends BaseProcess
{
/**
* @return string
*/
public function getName(): string
{
return "Rpc Manager";
}
/**
* @param Process|null $process
* @return void
*/
public function process(?Process $process): void
{
}
/**
* @return $this
*/
public function onSigterm(): static
{
// TODO: Implement onSigterm() method.
if (Context::inCoroutine()) {
Coroutine::create(fn() => $this->onShutdown(Coroutine::waitSignal(SIGTERM | SIGINT)));
} else {
2024-04-24 14:31:06 +08:00
\pcntl_signal(SIGTERM, [$this, 'onStop']);
\pcntl_signal(SIGINT, [$this, 'onStop']);
2023-07-31 23:09:00 +08:00
}
return $this;
}
}