modify plugin name
This commit is contained in:
+14
-1
@@ -4,6 +4,7 @@ namespace Kiri\Server\Coroutine;
|
|||||||
|
|
||||||
use Kiri\Abstracts\Component;
|
use Kiri\Abstracts\Component;
|
||||||
use Kiri\Exception\ConfigException;
|
use Kiri\Exception\ConfigException;
|
||||||
|
use Kiri\Message\Handler\Router;
|
||||||
use Kiri\Server\Constant;
|
use Kiri\Server\Constant;
|
||||||
use Kiri\Server\ProcessManager;
|
use Kiri\Server\ProcessManager;
|
||||||
use Kiri\Server\TraitServer;
|
use Kiri\Server\TraitServer;
|
||||||
@@ -30,6 +31,15 @@ class Http extends Component
|
|||||||
private array $configs = [];
|
private array $configs = [];
|
||||||
|
|
||||||
|
|
||||||
|
public Router $collector;
|
||||||
|
|
||||||
|
|
||||||
|
public function init()
|
||||||
|
{
|
||||||
|
$this->collector = \Kiri::getDi()->get(Router::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return void
|
* @return void
|
||||||
* @throws ContainerExceptionInterface
|
* @throws ContainerExceptionInterface
|
||||||
@@ -89,7 +99,7 @@ class Http extends Component
|
|||||||
public function initBaseServer(array $config, $daemon)
|
public function initBaseServer(array $config, $daemon)
|
||||||
{
|
{
|
||||||
$this->configs = $config;
|
$this->configs = $config;
|
||||||
foreach ($config as $value) {
|
foreach ($config['port'] as $value) {
|
||||||
$this->_addListener($value);
|
$this->_addListener($value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -191,6 +201,9 @@ class Http extends Component
|
|||||||
{
|
{
|
||||||
run(function () {
|
run(function () {
|
||||||
$this->startTaskWorker($this->configs);
|
$this->startTaskWorker($this->configs);
|
||||||
|
|
||||||
|
$this->collector->scan_build_route();
|
||||||
|
|
||||||
foreach ($this->servers as $value) {
|
foreach ($this->servers as $value) {
|
||||||
Coroutine::create(function () use ($value) {
|
Coroutine::create(function () use ($value) {
|
||||||
$value->start();
|
$value->start();
|
||||||
|
|||||||
+3
-3
@@ -11,9 +11,9 @@ use Kiri\Annotation\Inject;
|
|||||||
use Kiri\Events\EventDispatch;
|
use Kiri\Events\EventDispatch;
|
||||||
use Kiri\Exception\ConfigException;
|
use Kiri\Exception\ConfigException;
|
||||||
use Kiri\Message\Handler\Abstracts\HttpService;
|
use Kiri\Message\Handler\Abstracts\HttpService;
|
||||||
|
use Kiri\Server\Events\OnServerBeforeStart;
|
||||||
use Kiri\Server\Events\OnShutdown;
|
use Kiri\Server\Events\OnShutdown;
|
||||||
use Psr\Container\ContainerExceptionInterface;
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
use Kiri\Server\Events\OnServerBeforeStart;
|
|
||||||
use Psr\Container\NotFoundExceptionInterface;
|
use Psr\Container\NotFoundExceptionInterface;
|
||||||
use ReflectionException;
|
use ReflectionException;
|
||||||
use Swoole\Coroutine;
|
use Swoole\Coroutine;
|
||||||
@@ -83,7 +83,7 @@ class Server extends HttpService
|
|||||||
* @throws ReflectionException
|
* @throws ReflectionException
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function start(): mixed
|
public function start(): void
|
||||||
{
|
{
|
||||||
$this->manager->initBaseServer(Config::get('server', [], true), $this->daemon);
|
$this->manager->initBaseServer(Config::get('server', [], true), $this->daemon);
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ class Server extends HttpService
|
|||||||
|
|
||||||
$this->getEventDispatch()->dispatch(new OnServerBeforeStart());
|
$this->getEventDispatch()->dispatch(new OnServerBeforeStart());
|
||||||
|
|
||||||
return $this->manager->start();
|
$this->manager->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user