modify plugin name

This commit is contained in:
2022-06-17 12:27:33 +08:00
parent 7fdf83cd3a
commit f85d2aa0a2
3 changed files with 12 additions and 2 deletions
+7
View File
@@ -9,6 +9,7 @@ use Kiri\Di\ContainerInterface;
use Kiri\Exception\ConfigException; use Kiri\Exception\ConfigException;
use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface; use Psr\Container\NotFoundExceptionInterface;
use Psr\Log\LoggerInterface;
use ReflectionException; use ReflectionException;
use Swoole\Server; use Swoole\Server;
use Kiri\Server\ServerInterface; use Kiri\Server\ServerInterface;
@@ -36,11 +37,13 @@ class AsyncServer
* @param Config $config * @param Config $config
* @param ContainerInterface $container * @param ContainerInterface $container
* @param EventDispatch $dispatch * @param EventDispatch $dispatch
* @param LoggerInterface $logger
* @param ProcessManager $processManager * @param ProcessManager $processManager
*/ */
public function __construct(public Config $config, public function __construct(public Config $config,
public ContainerInterface $container, public ContainerInterface $container,
public EventDispatch $dispatch, public EventDispatch $dispatch,
public LoggerInterface $logger,
public ProcessManager $processManager) public ProcessManager $processManager)
{ {
} }
@@ -96,6 +99,8 @@ class AsyncServer
$this->server->set($this->systemConfig($config, $daemon)); $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::get('server.events', []));
$this->onEventListen($this->server, $config->events); $this->onEventListen($this->server, $config->events);
@@ -137,6 +142,8 @@ class AsyncServer
throw new Exception('Listen port fail.' . swoole_last_error()); 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)); $port->set($this->resetSettings($config->type, $config->settings));
$this->onEventListen($port, $config->getEvents()); $this->onEventListen($port, $config->getEvents());
+4 -1
View File
@@ -27,7 +27,7 @@ abstract class BaseProcess implements OnProcessInterface
protected bool $enable_coroutine = true; 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 public function getName(): string
{ {
if (empty($this->name)) {
return uniqid('p.');
}
return $this->name; return $this->name;
} }
+1 -1
View File
@@ -46,7 +46,7 @@ class ProcessManager
$system = sprintf('[%s].Custom Process', Config::get('id', 'system-service')); $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()) { if (Context::inCoroutine()) {
return [$customProcess, $this->resolve($customProcess, $system)]; return [$customProcess, $this->resolve($customProcess, $system)];
} }