Files
kiri-rpc/RpcProcess.php
T

47 lines
893 B
PHP
Raw Normal View History

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