Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 80cf72adc9 | |||
| dabcea452a | |||
| 2feda943af | |||
| bffe375230 | |||
| efb69d02f3 | |||
| 79e5fa0b08 | |||
| de7e005b46 | |||
| a64fa8f493 | |||
| c19e141f68 | |||
| 94a522588d | |||
| 308c992fd3 | |||
| 458c6cbd22 | |||
| b717a7e9f7 | |||
| 6786b313b5 |
@@ -3,7 +3,7 @@
|
|||||||
namespace Server\Abstracts;
|
namespace Server\Abstracts;
|
||||||
|
|
||||||
|
|
||||||
use JetBrains\PhpStorm\Pure;
|
use Kiri\Context;
|
||||||
use Server\Contract\OnProcessInterface;
|
use Server\Contract\OnProcessInterface;
|
||||||
use Swoole\Coroutine;
|
use Swoole\Coroutine;
|
||||||
use Swoole\Process;
|
use Swoole\Process;
|
||||||
@@ -17,7 +17,7 @@ abstract class BaseProcess implements OnProcessInterface
|
|||||||
protected bool $isStop = false;
|
protected bool $isStop = false;
|
||||||
|
|
||||||
|
|
||||||
protected mixed $redirect_stdin_and_stdout = null;
|
protected bool $redirect_stdin_and_stdout = FALSE;
|
||||||
|
|
||||||
|
|
||||||
protected int $pipe_type = SOCK_DGRAM;
|
protected int $pipe_type = SOCK_DGRAM;
|
||||||
@@ -47,10 +47,10 @@ abstract class BaseProcess implements OnProcessInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function getRedirectStdinAndStdout(): mixed
|
public function getRedirectStdinAndStdout(): bool
|
||||||
{
|
{
|
||||||
return $this->redirect_stdin_and_stdout;
|
return $this->redirect_stdin_and_stdout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,4 +80,32 @@ abstract class BaseProcess implements OnProcessInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function onSigterm(): static
|
||||||
|
{
|
||||||
|
if (!Context::inCoroutine()) {
|
||||||
|
Process::signal(SIGTERM, fn($data) => $this->onShutdown($data));
|
||||||
|
} else {
|
||||||
|
Coroutine::create(function () {
|
||||||
|
$data = Coroutine::waitSignal(SIGTERM, -1);
|
||||||
|
if ($data) {
|
||||||
|
$this->onShutdown($data);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $data
|
||||||
|
*/
|
||||||
|
protected function onShutdown($data): void
|
||||||
|
{
|
||||||
|
$this->isStop = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ namespace Server\Handler;
|
|||||||
use Note\Inject;
|
use Note\Inject;
|
||||||
use Kiri\Events\EventDispatch;
|
use Kiri\Events\EventDispatch;
|
||||||
use Kiri\Exception\ConfigException;
|
use Kiri\Exception\ConfigException;
|
||||||
|
use ReflectionException;
|
||||||
use Server\Abstracts\Server;
|
use Server\Abstracts\Server;
|
||||||
use Server\Events\OnBeforeShutdown;
|
use Server\Events\OnBeforeShutdown;
|
||||||
use Server\Events\OnShutdown;
|
use Server\Events\OnShutdown;
|
||||||
@@ -28,6 +29,7 @@ class OnServer extends Server
|
|||||||
/**
|
/**
|
||||||
* @param \Swoole\Server $server
|
* @param \Swoole\Server $server
|
||||||
* @throws ConfigException
|
* @throws ConfigException
|
||||||
|
* @throws ReflectionException
|
||||||
*/
|
*/
|
||||||
public function onStart(\Swoole\Server $server)
|
public function onStart(\Swoole\Server $server)
|
||||||
{
|
{
|
||||||
@@ -39,6 +41,7 @@ class OnServer extends Server
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Swoole\Server $server
|
* @param \Swoole\Server $server
|
||||||
|
* @throws ReflectionException
|
||||||
*/
|
*/
|
||||||
public function onBeforeShutdown(\Swoole\Server $server)
|
public function onBeforeShutdown(\Swoole\Server $server)
|
||||||
{
|
{
|
||||||
@@ -48,6 +51,7 @@ class OnServer extends Server
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Swoole\Server $server
|
* @param \Swoole\Server $server
|
||||||
|
* @throws ReflectionException
|
||||||
*/
|
*/
|
||||||
public function onShutdown(\Swoole\Server $server)
|
public function onShutdown(\Swoole\Server $server)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace Server\Handler;
|
|||||||
|
|
||||||
use Note\Inject;
|
use Note\Inject;
|
||||||
use Kiri\Events\EventDispatch;
|
use Kiri\Events\EventDispatch;
|
||||||
|
use ReflectionException;
|
||||||
use Server\Abstracts\Server;
|
use Server\Abstracts\Server;
|
||||||
use Kiri\Exception\ConfigException;
|
use Kiri\Exception\ConfigException;
|
||||||
use Server\Events\OnManagerStart;
|
use Server\Events\OnManagerStart;
|
||||||
@@ -26,8 +27,8 @@ class OnServerManager extends Server
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Swoole\Server $server
|
* @param \Swoole\Server $server
|
||||||
* @throws ConfigException
|
* @throws ConfigException|ReflectionException
|
||||||
*/
|
*/
|
||||||
public function onManagerStart(\Swoole\Server $server)
|
public function onManagerStart(\Swoole\Server $server)
|
||||||
{
|
{
|
||||||
$this->setProcessName(sprintf('manger[%d].0', $server->manager_pid));
|
$this->setProcessName(sprintf('manger[%d].0', $server->manager_pid));
|
||||||
@@ -38,6 +39,7 @@ class OnServerManager extends Server
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Swoole\Server $server
|
* @param \Swoole\Server $server
|
||||||
|
* @throws ReflectionException
|
||||||
*/
|
*/
|
||||||
public function onManagerStop(\Swoole\Server $server)
|
public function onManagerStop(\Swoole\Server $server)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ class OnServerReload
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Server $server
|
* @param Server $server
|
||||||
|
* @throws \ReflectionException
|
||||||
*/
|
*/
|
||||||
public function onBeforeReload(Server $server)
|
public function onBeforeReload(Server $server)
|
||||||
{
|
{
|
||||||
@@ -34,6 +35,7 @@ class OnServerReload
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Server $server
|
* @param Server $server
|
||||||
|
* @throws \ReflectionException
|
||||||
*/
|
*/
|
||||||
public function onAfterReload(Server $server)
|
public function onAfterReload(Server $server)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
namespace Server\Handler;
|
namespace Server\Handler;
|
||||||
|
|
||||||
use Note\Inject;
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Kiri\Abstracts\Config;
|
use Kiri\Abstracts\Config;
|
||||||
use Kiri\Core\Help;
|
use Kiri\Core\Help;
|
||||||
use Kiri\Events\EventDispatch;
|
use Kiri\Events\EventDispatch;
|
||||||
use Kiri\Kiri;
|
use Kiri\Kiri;
|
||||||
|
use Note\Inject;
|
||||||
use Server\Events\OnAfterWorkerStart;
|
use Server\Events\OnAfterWorkerStart;
|
||||||
use Server\Events\OnBeforeWorkerStart;
|
use Server\Events\OnBeforeWorkerStart;
|
||||||
use Server\Events\OnTaskerStart as OnTaskStart;
|
use Server\Events\OnTaskerStart as OnTaskStart;
|
||||||
@@ -62,8 +62,8 @@ class OnServerWorker extends \Server\Abstracts\Server
|
|||||||
*/
|
*/
|
||||||
public function onWorkerStop(Server $server, int $workerId)
|
public function onWorkerStop(Server $server, int $workerId)
|
||||||
{
|
{
|
||||||
Timer::clearAll();
|
Timer::clearAll();
|
||||||
$this->eventDispatch->dispatch(new OnWorkerStop($server, $workerId));
|
$this->eventDispatch->dispatch(new OnWorkerStop($server, $workerId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -76,8 +76,8 @@ class OnServerWorker extends \Server\Abstracts\Server
|
|||||||
{
|
{
|
||||||
set_env('state', 'exit');
|
set_env('state', 'exit');
|
||||||
|
|
||||||
$this->eventDispatch->dispatch(new OnWorkerExit($server, $workerId));
|
$this->eventDispatch->dispatch(new OnWorkerExit($server, $workerId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -98,7 +98,7 @@ class OnServerWorker extends \Server\Abstracts\Server
|
|||||||
|
|
||||||
$this->logger->error($message);
|
$this->logger->error($message);
|
||||||
|
|
||||||
// $this->system_mail($message);
|
$this->system_mail($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -109,7 +109,7 @@ class OnServerWorker extends \Server\Abstracts\Server
|
|||||||
protected function system_mail($messageContent)
|
protected function system_mail($messageContent)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$email = Config::get('email');
|
$email = Config::get('email', ['enable' => false]);
|
||||||
if (!empty($email) && ($email['enable'] ?? false) == true) {
|
if (!empty($email) && ($email['enable'] ?? false) == true) {
|
||||||
Help::sendEmail($email, 'Service Error', $messageContent);
|
Help::sendEmail($email, 'Service Error', $messageContent);
|
||||||
}
|
}
|
||||||
|
|||||||
+24
-23
@@ -5,10 +5,10 @@ namespace Server;
|
|||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Http\Handler\Abstracts\HttpService;
|
use Http\Handler\Abstracts\HttpService;
|
||||||
use JetBrains\PhpStorm\Pure;
|
|
||||||
use Kiri\Abstracts\Config;
|
use Kiri\Abstracts\Config;
|
||||||
use Kiri\Events\EventDispatch;
|
use Kiri\Events\EventDispatch;
|
||||||
use Kiri\Exception\ConfigException;
|
use Kiri\Exception\ConfigException;
|
||||||
|
use Kiri\Kiri;
|
||||||
use Note\Inject;
|
use Note\Inject;
|
||||||
use Psr\Container\ContainerExceptionInterface;
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
use Psr\Container\NotFoundExceptionInterface;
|
use Psr\Container\NotFoundExceptionInterface;
|
||||||
@@ -28,21 +28,9 @@ class Server extends HttpService
|
|||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Inject ServerManager
|
|
||||||
* @var null|ServerManager
|
|
||||||
*/
|
|
||||||
#[Inject(ServerManager::class)]
|
|
||||||
public ?ServerManager $manager = null;
|
|
||||||
|
|
||||||
private mixed $daemon = 0;
|
private mixed $daemon = 0;
|
||||||
|
|
||||||
|
|
||||||
/** @var EventDispatch */
|
|
||||||
#[Inject(EventDispatch::class)]
|
|
||||||
public EventDispatch $eventDispatch;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var State
|
* @var State
|
||||||
*/
|
*/
|
||||||
@@ -77,36 +65,38 @@ class Server extends HttpService
|
|||||||
*/
|
*/
|
||||||
public function start(): string
|
public function start(): string
|
||||||
{
|
{
|
||||||
$this->manager->initBaseServer(Config::get('server', [], true), $this->daemon);
|
$this->manager()->initBaseServer(Config::get('server', [], true), $this->daemon);
|
||||||
|
|
||||||
$rpcService = Config::get('rpc', []);
|
$rpcService = Config::get('rpc', []);
|
||||||
if (!empty($rpcService)) {
|
if (!empty($rpcService)) {
|
||||||
$this->manager->addListener($rpcService['type'], $rpcService['host'], $rpcService['port'],
|
$this->manager()->addListener($rpcService['type'], $rpcService['host'], $rpcService['port'],
|
||||||
$rpcService['mode'], $rpcService);
|
$rpcService['mode'], $rpcService);
|
||||||
}
|
}
|
||||||
|
|
||||||
$processes = array_merge($this->process, Config::get('processes', []));
|
$processes = array_merge($this->process, Config::get('processes', []));
|
||||||
foreach ($processes as $process) {
|
foreach ($processes as $process) {
|
||||||
$this->manager->addProcess($process);
|
$this->manager()->addProcess($process);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->manager->getServer()->start();
|
return $this->manager()->getServer()->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return void
|
* @return void
|
||||||
*
|
* @throws ConfigException
|
||||||
* start server
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
|
* @throws \ReflectionException
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function shutdown()
|
public function shutdown()
|
||||||
{
|
{
|
||||||
$configs = Config::get('server', [], true);
|
$configs = Config::get('server', [], true);
|
||||||
foreach ($this->manager->sortService($configs['ports'] ?? []) as $config) {
|
foreach ($this->manager()->sortService($configs['ports'] ?? []) as $config) {
|
||||||
$this->state->exit($config['port']);
|
$this->state->exit($config['port']);
|
||||||
}
|
}
|
||||||
$this->eventDispatch->dispatch(new OnShutdown());
|
$this->container->get(EventDispatch::class)->dispatch(new OnShutdown());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -137,10 +127,21 @@ class Server extends HttpService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \Swoole\Http\Server|\Swoole\Server|\Swoole\WebSocket\Server|null
|
* @return \Swoole\Http\Server|\Swoole\Server|\Swoole\WebSocket\Server|null
|
||||||
|
* @throws \ReflectionException
|
||||||
*/
|
*/
|
||||||
#[Pure] public function getServer(): \Swoole\Http\Server|\Swoole\Server|\Swoole\WebSocket\Server|null
|
public function getServer(): \Swoole\Http\Server|\Swoole\Server|\Swoole\WebSocket\Server|null
|
||||||
{
|
{
|
||||||
return $this->manager->getServer();
|
return $this->manager()->getServer();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return ServerManager
|
||||||
|
* @throws \ReflectionException
|
||||||
|
*/
|
||||||
|
private function manager(): ServerManager
|
||||||
|
{
|
||||||
|
return Kiri::getDi()->get(ServerManager::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ use Kiri\Abstracts\Config;
|
|||||||
use Kiri\Events\EventDispatch;
|
use Kiri\Events\EventDispatch;
|
||||||
use Kiri\Exception\ConfigException;
|
use Kiri\Exception\ConfigException;
|
||||||
use Kiri\Kiri;
|
use Kiri\Kiri;
|
||||||
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
|
use Psr\Container\NotFoundExceptionInterface;
|
||||||
use Server\Events\OnServerBeforeStart;
|
use Server\Events\OnServerBeforeStart;
|
||||||
use Swoole\Coroutine;
|
use Swoole\Coroutine;
|
||||||
use Symfony\Component\Console\Command\Command;
|
use Symfony\Component\Console\Command\Command;
|
||||||
@@ -52,6 +54,10 @@ class ServerCommand extends Command
|
|||||||
* @param InputInterface $input
|
* @param InputInterface $input
|
||||||
* @param OutputInterface $output
|
* @param OutputInterface $output
|
||||||
* @return int
|
* @return int
|
||||||
|
* @throws ConfigException
|
||||||
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
|
* @throws \ReflectionException
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function execute(InputInterface $input, OutputInterface $output): int
|
public function execute(InputInterface $input, OutputInterface $output): int
|
||||||
|
|||||||
+23
-29
@@ -3,15 +3,14 @@
|
|||||||
namespace Server;
|
namespace Server;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use Kiri\Abstracts\Component;
|
||||||
use Kiri\Abstracts\Config;
|
use Kiri\Abstracts\Config;
|
||||||
use Kiri\Di\Container;
|
|
||||||
use Kiri\Error\Logger;
|
use Kiri\Error\Logger;
|
||||||
use Kiri\Events\EventDispatch;
|
use Kiri\Events\EventDispatch;
|
||||||
use Kiri\Exception\ConfigException;
|
use Kiri\Exception\ConfigException;
|
||||||
use Kiri\Kiri;
|
use Kiri\Kiri;
|
||||||
use Note\Inject;
|
use Note\Inject;
|
||||||
use Psr\Container\ContainerExceptionInterface;
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
use Psr\Container\ContainerInterface;
|
|
||||||
use Psr\Container\NotFoundExceptionInterface;
|
use Psr\Container\NotFoundExceptionInterface;
|
||||||
use ReflectionException;
|
use ReflectionException;
|
||||||
use Server\Abstracts\BaseProcess;
|
use Server\Abstracts\BaseProcess;
|
||||||
@@ -41,7 +40,7 @@ use Swoole\WebSocket\Server as WServer;
|
|||||||
* Class OnServerManager
|
* Class OnServerManager
|
||||||
* @package Http\Service
|
* @package Http\Service
|
||||||
*/
|
*/
|
||||||
class ServerManager
|
class ServerManager extends Component
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
@@ -59,14 +58,6 @@ class ServerManager
|
|||||||
#[Inject(Logger::class)]
|
#[Inject(Logger::class)]
|
||||||
public Logger $logger;
|
public Logger $logger;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var State
|
|
||||||
*/
|
|
||||||
#[Inject(State::class)]
|
|
||||||
public State $state;
|
|
||||||
|
|
||||||
|
|
||||||
/** @var array<string,Port> */
|
/** @var array<string,Port> */
|
||||||
public array $ports = [];
|
public array $ports = [];
|
||||||
|
|
||||||
@@ -76,11 +67,7 @@ class ServerManager
|
|||||||
private Server|null $server = null;
|
private Server|null $server = null;
|
||||||
|
|
||||||
|
|
||||||
/**
|
protected array $initProcesses = [];
|
||||||
* @var Container
|
|
||||||
*/
|
|
||||||
#[Inject(ContainerInterface::class)]
|
|
||||||
public ContainerInterface $container;
|
|
||||||
|
|
||||||
|
|
||||||
const DEFAULT_EVENT = [
|
const DEFAULT_EVENT = [
|
||||||
@@ -129,7 +116,6 @@ class ServerManager
|
|||||||
* @throws ConfigException
|
* @throws ConfigException
|
||||||
* @throws ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
* @throws ReflectionException
|
|
||||||
*/
|
*/
|
||||||
public function addListener(string $type, string $host, int $port, int $mode, array $settings = [])
|
public function addListener(string $type, string $host, int $port, int $mode, array $settings = [])
|
||||||
{
|
{
|
||||||
@@ -172,15 +158,26 @@ class ServerManager
|
|||||||
$customProcess = Kiri::getDi()->get($customProcess);
|
$customProcess = Kiri::getDi()->get($customProcess);
|
||||||
}
|
}
|
||||||
$system = sprintf('[%s].process', Config::get('id', 'system-service'));
|
$system = sprintf('[%s].process', Config::get('id', 'system-service'));
|
||||||
$process = new Process(function (Process $process) use ($customProcess, $system) {
|
$this->logger->debug($system . ' ' . $customProcess->getName() . ' start.');
|
||||||
|
$this->server->addProcess(new Process(function (Process $process) use ($customProcess, $system) {
|
||||||
if (Kiri::getPlatform()->isLinux()) {
|
if (Kiri::getPlatform()->isLinux()) {
|
||||||
$process->name($system . '(' . $customProcess->getName() . ')');
|
$process->name($system . '(' . $customProcess->getName() . ')');
|
||||||
}
|
}
|
||||||
$customProcess->process($process);
|
$customProcess->onSigterm()->process($process);
|
||||||
}, $customProcess->getRedirectStdinAndStdout(), $customProcess->getPipeType(), $customProcess->isEnableCoroutine());
|
},
|
||||||
$this->logger->debug($system . ' ' . $customProcess->getName() . ' start.');
|
$customProcess->getRedirectStdinAndStdout(),
|
||||||
$this->container->setBindings($customProcess->getName(), $process);
|
$customProcess->getPipeType(),
|
||||||
$this->server->addProcess($process);
|
$customProcess->isEnableCoroutine()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string,Process>
|
||||||
|
*/
|
||||||
|
public function getProcesses(): array
|
||||||
|
{
|
||||||
|
return $this->initProcesses;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -279,7 +276,6 @@ class ServerManager
|
|||||||
* @throws ConfigException
|
* @throws ConfigException
|
||||||
* @throws ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
* @throws ReflectionException
|
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private function createBaseServer(string $type, string $host, int $port, int $mode, array $settings = [])
|
private function createBaseServer(string $type, string $host, int $port, int $mode, array $settings = [])
|
||||||
@@ -295,7 +291,7 @@ class ServerManager
|
|||||||
|
|
||||||
$id = Config::get('id', 'system-service');
|
$id = Config::get('id', 'system-service');
|
||||||
|
|
||||||
$this->logger->debug(sprintf('[%s]' . $type . ' service %s::%d start', $id, $host, $port));
|
$this->logger->debug(sprintf('[%s].' . $type . ' service %s::%d start', $id, $host, $port));
|
||||||
|
|
||||||
$this->addDefaultListener($settings);
|
$this->addDefaultListener($settings);
|
||||||
}
|
}
|
||||||
@@ -305,7 +301,6 @@ class ServerManager
|
|||||||
* @param array $settings
|
* @param array $settings
|
||||||
* @throws ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
* @throws ReflectionException
|
|
||||||
*/
|
*/
|
||||||
private function addDefaultListener(array $settings): void
|
private function addDefaultListener(array $settings): void
|
||||||
{
|
{
|
||||||
@@ -325,7 +320,6 @@ class ServerManager
|
|||||||
* @param Server|Port $server
|
* @param Server|Port $server
|
||||||
* @throws ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
* @throws ReflectionException
|
|
||||||
*/
|
*/
|
||||||
private function addServiceEvents(array $events, Server|Port $server)
|
private function addServiceEvents(array $events, Server|Port $server)
|
||||||
{
|
{
|
||||||
@@ -360,9 +354,9 @@ class ServerManager
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $events
|
* @param array $events
|
||||||
|
* @return void
|
||||||
* @throws ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
* @throws ReflectionException
|
|
||||||
*/
|
*/
|
||||||
private function addTaskListener(array $events = []): void
|
private function addTaskListener(array $events = []): void
|
||||||
{
|
{
|
||||||
@@ -379,9 +373,9 @@ class ServerManager
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array|null $settings
|
* @param array|null $settings
|
||||||
|
* @return void
|
||||||
* @throws ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
* @throws NotFoundExceptionInterface
|
* @throws NotFoundExceptionInterface
|
||||||
* @throws ReflectionException
|
|
||||||
*/
|
*/
|
||||||
public function bindCallback(?array $settings = [])
|
public function bindCallback(?array $settings = [])
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,11 +3,11 @@
|
|||||||
namespace Server;
|
namespace Server;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Kiri\Abstracts\BaseObject;
|
use Kiri\Abstracts\Component;
|
||||||
use Kiri\Abstracts\Config;
|
use Kiri\Abstracts\Config;
|
||||||
use Swoole\Process;
|
use Swoole\Process;
|
||||||
|
|
||||||
class State extends BaseObject
|
class State extends Component
|
||||||
{
|
{
|
||||||
|
|
||||||
use TraitServer;
|
use TraitServer;
|
||||||
|
|||||||
@@ -3,12 +3,9 @@
|
|||||||
namespace Server\Tasker;
|
namespace Server\Tasker;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Kiri\Abstracts\BaseObject;
|
use Kiri\Abstracts\Component;
|
||||||
use Kiri\Core\HashMap;
|
use Kiri\Core\HashMap;
|
||||||
use Kiri\Di\Container;
|
|
||||||
use Kiri\Kiri;
|
use Kiri\Kiri;
|
||||||
use Note\Inject;
|
|
||||||
use Psr\Container\ContainerInterface;
|
|
||||||
use ReflectionException;
|
use ReflectionException;
|
||||||
use Server\Contract\OnTaskInterface;
|
use Server\Contract\OnTaskInterface;
|
||||||
use Server\SwooleServerInterface;
|
use Server\SwooleServerInterface;
|
||||||
@@ -17,7 +14,7 @@ use Server\SwooleServerInterface;
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class AsyncTaskExecute extends BaseObject
|
class AsyncTaskExecute extends Component
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
@@ -27,13 +24,6 @@ class AsyncTaskExecute extends BaseObject
|
|||||||
public ?SwooleServerInterface $server = null;
|
public ?SwooleServerInterface $server = null;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var Container
|
|
||||||
*/
|
|
||||||
#[Inject(ContainerInterface::class)]
|
|
||||||
public ContainerInterface $container;
|
|
||||||
|
|
||||||
|
|
||||||
private HashMap $hashMap;
|
private HashMap $hashMap;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ namespace Server\Tasker;
|
|||||||
use Note\Inject;
|
use Note\Inject;
|
||||||
use Kiri\Abstracts\Logger;
|
use Kiri\Abstracts\Logger;
|
||||||
use Kiri\Exception\ConfigException;
|
use Kiri\Exception\ConfigException;
|
||||||
use ReflectionException;
|
|
||||||
use Server\Contract\OnTaskInterface;
|
use Server\Contract\OnTaskInterface;
|
||||||
use Swoole\Server;
|
use Swoole\Server;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user