From f85d2aa0a2a6860ea21e706f08ec058ca51d4459 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Fri, 17 Jun 2022 12:27:33 +0800 Subject: [PATCH] modify plugin name --- Abstracts/AsyncServer.php | 7 +++++++ Abstracts/BaseProcess.php | 5 ++++- Abstracts/ProcessManager.php | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Abstracts/AsyncServer.php b/Abstracts/AsyncServer.php index 4d4b6f1..7b3e2b3 100644 --- a/Abstracts/AsyncServer.php +++ b/Abstracts/AsyncServer.php @@ -9,6 +9,7 @@ use Kiri\Di\ContainerInterface; use Kiri\Exception\ConfigException; use Psr\Container\ContainerExceptionInterface; use Psr\Container\NotFoundExceptionInterface; +use Psr\Log\LoggerInterface; use ReflectionException; use Swoole\Server; use Kiri\Server\ServerInterface; @@ -36,11 +37,13 @@ class AsyncServer * @param Config $config * @param ContainerInterface $container * @param EventDispatch $dispatch + * @param LoggerInterface $logger * @param ProcessManager $processManager */ public function __construct(public Config $config, public ContainerInterface $container, public EventDispatch $dispatch, + public LoggerInterface $logger, public ProcessManager $processManager) { } @@ -96,6 +99,8 @@ class AsyncServer $this->server->set($this->systemConfig($config, $daemon)); + $this->logger->alert('Listen ' . $config->type . ' address ' . $config->host . '::' . $config->port); + $this->onEventListen($this->server, Config::get('server.events', [])); $this->onEventListen($this->server, $config->events); @@ -137,6 +142,8 @@ class AsyncServer throw new Exception('Listen port fail.' . swoole_last_error()); } + $this->logger->alert('Listen ' . $config->type . ' address ' . $config->host . '::' . $config->port); + $port->set($this->resetSettings($config->type, $config->settings)); $this->onEventListen($port, $config->getEvents()); diff --git a/Abstracts/BaseProcess.php b/Abstracts/BaseProcess.php index 3c77dc7..1e7d7c5 100644 --- a/Abstracts/BaseProcess.php +++ b/Abstracts/BaseProcess.php @@ -27,7 +27,7 @@ abstract class BaseProcess implements OnProcessInterface protected bool $enable_coroutine = true; - public string $name = 'swoole process.'; + public string $name = ''; /** @@ -35,6 +35,9 @@ abstract class BaseProcess implements OnProcessInterface */ public function getName(): string { + if (empty($this->name)) { + return uniqid('p.'); + } return $this->name; } diff --git a/Abstracts/ProcessManager.php b/Abstracts/ProcessManager.php index 6fab1f8..7341eb6 100644 --- a/Abstracts/ProcessManager.php +++ b/Abstracts/ProcessManager.php @@ -46,7 +46,7 @@ class ProcessManager $system = sprintf('[%s].Custom Process', Config::get('id', 'system-service')); - $this->logger->debug($system . ' ' . $customProcess->getName() . ' start.'); + $this->logger->alert($system . ' ' . $customProcess->getName() . ' start.'); if (Context::inCoroutine()) { return [$customProcess, $this->resolve($customProcess, $system)]; }