modify plugin name

This commit is contained in:
2022-06-20 18:00:00 +08:00
parent 5e8d9ceae7
commit b20c8fc5a3
2 changed files with 17 additions and 24 deletions
+8 -10
View File
@@ -5,6 +5,7 @@ namespace Kiri\Server\Abstracts;
use Kiri\Abstracts\Config;
use Kiri\Di\ContainerInterface;
use Kiri\Events\EventDispatch;
use Kiri\Exception\ConfigException;
use Kiri\Server\Constant;
use Kiri\Server\Events\OnWorkerStart;
use Kiri\Server\Events\OnWorkerStop;
@@ -78,9 +79,9 @@ class CoroutineServer implements ServerInterface
{
// TODO: Implement initCoreServers() method.
$this->servers = $this->genConfigService($service);
// foreach ($service as $value) {
// $this->addListener($value);
// }
foreach ($service as $value) {
$this->addListener($value);
}
}
@@ -165,19 +166,16 @@ class CoroutineServer implements ServerInterface
/**
* @return void
* @throws ConfigException
*/
public function start(): void
{
// TODO: Implement start() method.
$merge = array_merge(Config::get('processes', []), $this->getProcess());
$this->processManager->batch($merge);
run(function () {
$this->processManager->batch(Config::get('processes', []));
$this->processManager->batch($this->getProcess());
foreach ($this->servers as $server) {
Coroutine::create(function () use ($server) {
$this->addListener($server);
$this->runServer($this->servers[$server->name]);
$this->runServer($server);
});
}
});
+9 -14
View File
@@ -12,7 +12,6 @@ use Kiri\Server\Broadcast\Message;
use Kiri\Server\Contract\OnProcessInterface;
use Kiri\Server\Events\OnProcessStart;
use Psr\Log\LoggerInterface;
use Swoole\Coroutine;
use Swoole\Process;
use Kiri\Server\Events\OnProcessStop;
use Kiri\Di\ContainerInterface;
@@ -129,17 +128,16 @@ class ProcessManager
if (empty($processes)) {
return;
}
if (Context::inCoroutine()) {
if (is_null($server)) {
$this->poolManager($processes);
return;
}
} else {
foreach ($processes as $process) {
[$customProcess, $sProcess] = $this->add($process);
foreach ($processes as $process) {
[$customProcess, $sProcess] = $this->add($process);
$this->_process[$customProcess->getName()] = $customProcess;
$this->_process[$customProcess->getName()] = $customProcess;
$server->addProcess($sProcess);
$server->addProcess($sProcess);
}
}
}
@@ -151,16 +149,13 @@ class ProcessManager
*/
protected function poolManager(array $processes): void
{
foreach ($processes as $process) {
/** @var BaseProcess $customProcess */
[$customProcess, $sProcess] = $this->add($process);
$this->_process[$customProcess->getName()] = $customProcess;
$this->_process[$customProcess->getName()] = $sProcess;
Coroutine::create(function () use ($customProcess) {
$customProcess->onSigterm()->process(null);
});
$sProcess->start();
}
}