modify plugin name
This commit is contained in:
@@ -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\Exception\ConfigException;
|
||||||
use Kiri\Server\Constant;
|
use Kiri\Server\Constant;
|
||||||
use Kiri\Server\Events\OnWorkerStart;
|
use Kiri\Server\Events\OnWorkerStart;
|
||||||
use Kiri\Server\Events\OnWorkerStop;
|
use Kiri\Server\Events\OnWorkerStop;
|
||||||
@@ -78,9 +79,9 @@ class CoroutineServer implements ServerInterface
|
|||||||
{
|
{
|
||||||
// TODO: Implement initCoreServers() method.
|
// TODO: Implement initCoreServers() method.
|
||||||
$this->servers = $this->genConfigService($service);
|
$this->servers = $this->genConfigService($service);
|
||||||
// foreach ($service as $value) {
|
foreach ($service as $value) {
|
||||||
// $this->addListener($value);
|
$this->addListener($value);
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -165,19 +166,16 @@ class CoroutineServer implements ServerInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return void
|
* @return void
|
||||||
|
* @throws ConfigException
|
||||||
*/
|
*/
|
||||||
public function start(): void
|
public function start(): void
|
||||||
{
|
{
|
||||||
// TODO: Implement start() method.
|
$merge = array_merge(Config::get('processes', []), $this->getProcess());
|
||||||
|
$this->processManager->batch($merge);
|
||||||
run(function () {
|
run(function () {
|
||||||
$this->processManager->batch(Config::get('processes', []));
|
|
||||||
$this->processManager->batch($this->getProcess());
|
|
||||||
|
|
||||||
foreach ($this->servers as $server) {
|
foreach ($this->servers as $server) {
|
||||||
Coroutine::create(function () use ($server) {
|
Coroutine::create(function () use ($server) {
|
||||||
$this->addListener($server);
|
$this->runServer($server);
|
||||||
|
|
||||||
$this->runServer($this->servers[$server->name]);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ use Kiri\Server\Broadcast\Message;
|
|||||||
use Kiri\Server\Contract\OnProcessInterface;
|
use Kiri\Server\Contract\OnProcessInterface;
|
||||||
use Kiri\Server\Events\OnProcessStart;
|
use Kiri\Server\Events\OnProcessStart;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Swoole\Coroutine;
|
|
||||||
use Swoole\Process;
|
use Swoole\Process;
|
||||||
use Kiri\Server\Events\OnProcessStop;
|
use Kiri\Server\Events\OnProcessStop;
|
||||||
use Kiri\Di\ContainerInterface;
|
use Kiri\Di\ContainerInterface;
|
||||||
@@ -129,11 +128,9 @@ class ProcessManager
|
|||||||
if (empty($processes)) {
|
if (empty($processes)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Context::inCoroutine()) {
|
if (is_null($server)) {
|
||||||
$this->poolManager($processes);
|
$this->poolManager($processes);
|
||||||
return;
|
} else {
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($processes as $process) {
|
foreach ($processes as $process) {
|
||||||
[$customProcess, $sProcess] = $this->add($process);
|
[$customProcess, $sProcess] = $this->add($process);
|
||||||
|
|
||||||
@@ -142,6 +139,7 @@ class ProcessManager
|
|||||||
$server->addProcess($sProcess);
|
$server->addProcess($sProcess);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -151,16 +149,13 @@ class ProcessManager
|
|||||||
*/
|
*/
|
||||||
protected function poolManager(array $processes): void
|
protected function poolManager(array $processes): void
|
||||||
{
|
{
|
||||||
|
|
||||||
foreach ($processes as $process) {
|
foreach ($processes as $process) {
|
||||||
/** @var BaseProcess $customProcess */
|
/** @var BaseProcess $customProcess */
|
||||||
[$customProcess, $sProcess] = $this->add($process);
|
[$customProcess, $sProcess] = $this->add($process);
|
||||||
|
|
||||||
$this->_process[$customProcess->getName()] = $customProcess;
|
$this->_process[$customProcess->getName()] = $sProcess;
|
||||||
|
|
||||||
Coroutine::create(function () use ($customProcess) {
|
$sProcess->start();
|
||||||
$customProcess->onSigterm()->process(null);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user