modify plugin name

This commit is contained in:
2022-06-22 10:53:58 +08:00
parent ea7618ed1b
commit ffa0c8c7f6
+14 -1
View File
@@ -5,6 +5,7 @@ namespace Kiri\Server\Abstracts;
use Kiri\Abstracts\Config; use Kiri\Abstracts\Config;
use Kiri\Di\ContainerInterface; use Kiri\Di\ContainerInterface;
use Kiri\Events\EventDispatch; use Kiri\Events\EventDispatch;
use Kiri\Events\EventProvider;
use Kiri\Exception\ConfigException; use Kiri\Exception\ConfigException;
use Kiri\Server\Constant; use Kiri\Server\Constant;
use Kiri\Server\Events\OnShutdown; use Kiri\Server\Events\OnShutdown;
@@ -42,6 +43,7 @@ class CoroutineServer implements ServerInterface
* @param Config $config * @param Config $config
* @param ContainerInterface $container * @param ContainerInterface $container
* @param EventDispatch $dispatch * @param EventDispatch $dispatch
* @param EventProvider $provider
* @param LoggerInterface $logger * @param LoggerInterface $logger
* @param ProcessManager $processManager * @param ProcessManager $processManager
* @param array $params * @param array $params
@@ -49,6 +51,7 @@ class CoroutineServer implements ServerInterface
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 EventProvider $provider,
public LoggerInterface $logger, public LoggerInterface $logger,
public ProcessManager $processManager, public ProcessManager $processManager,
public array $params = [] public array $params = []
@@ -82,6 +85,11 @@ class CoroutineServer implements ServerInterface
*/ */
public function initCoreServers(array $service, int $daemon = 0): void public function initCoreServers(array $service, int $daemon = 0): void
{ {
$this->provider->on(OnShutdown::class, function () {
$process = $this->container->get(ProcessManager::class);
$process->shutdown();
});
// TODO: Implement initCoreServers() method. // TODO: Implement initCoreServers() method.
$service = $this->genConfigService($service); $service = $this->genConfigService($service);
foreach ($service as $value) { foreach ($service as $value) {
@@ -189,11 +197,16 @@ class CoroutineServer implements ServerInterface
*/ */
public function start(): void public function start(): void
{ {
run(function () {
$provider = $this->container->get(EventProvider::class);
$merge = array_merge(Config::get('processes', []), $this->getProcess()); $merge = array_merge(Config::get('processes', []), $this->getProcess());
$this->processManager->batch($merge); $this->processManager->batch($merge);
run(function () {
foreach ($this->servers as $server) { foreach ($this->servers as $server) {
Coroutine::create(function () use ($server) { Coroutine::create(function () use ($server) {
$this->runServer($server); $this->runServer($server);
}); });
} }