r
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace Kiri\Actor;
|
||||
|
||||
use Kiri\Server\Abstracts\BaseProcess;
|
||||
use Swoole\Coroutine;
|
||||
use Swoole\Process;
|
||||
|
||||
class ActorProcess extends BaseProcess
|
||||
{
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected bool $enable_coroutine = true;
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
// TODO: Change the autogenerated stub
|
||||
return '[' . \config('id', 'system-service') . '].Actor Manager';
|
||||
}
|
||||
|
||||
|
||||
public function process(?Process $process): void
|
||||
{
|
||||
// TODO: Implement process() method.
|
||||
while ($this->isStop() === false) {
|
||||
$read = $process->read();
|
||||
|
||||
ActorManager::exec(json_decode($read, true));
|
||||
|
||||
Coroutine::sleep(1000 / 120);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function onSigterm(): static
|
||||
{
|
||||
// TODO: Implement onSigterm() method.
|
||||
Coroutine::create(function () {
|
||||
$sign = Coroutine::waitSignal(SIGINT | SIGTERM);
|
||||
if ($sign) {
|
||||
$this->onShutdown(true);
|
||||
}
|
||||
});
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user