Revert "改名"

This reverts commit fdf58326
This commit is contained in:
2022-01-12 14:43:28 +08:00
parent d707b7f384
commit 02d0c9a8fd
3 changed files with 7 additions and 59 deletions
+3 -1
View File
@@ -3,11 +3,12 @@
namespace Kiri\Server\Handler; namespace Kiri\Server\Handler;
use Exception; use Exception;
use Kiri;
use Kiri\Abstracts\Config; use Kiri\Abstracts\Config;
use Kiri\Annotation\Inject; use Kiri\Annotation\Inject;
use Kiri\Core\Help; use Kiri\Core\Help;
use Kiri\Events\EventDispatch; use Kiri\Events\EventDispatch;
use Kiri; use Kiri\Message\Handler\Router;
use Kiri\Server\Events\OnAfterWorkerStart; use Kiri\Server\Events\OnAfterWorkerStart;
use Kiri\Server\Events\OnBeforeWorkerStart; use Kiri\Server\Events\OnBeforeWorkerStart;
use Kiri\Server\Events\OnTaskerStart as OnTaskStart; use Kiri\Server\Events\OnTaskerStart as OnTaskStart;
@@ -44,6 +45,7 @@ class OnServerWorker extends \Kiri\Server\Abstracts\Server
$this->eventDispatch->dispatch(new OnBeforeWorkerStart($workerId)); $this->eventDispatch->dispatch(new OnBeforeWorkerStart($workerId));
set_env('environmental_workerId', $workerId); set_env('environmental_workerId', $workerId);
if ($workerId < $server->setting['worker_num']) { if ($workerId < $server->setting['worker_num']) {
Kiri::getContainer()->get(Router::class)->scan_build_route();
$this->eventDispatch->dispatch(new OnWorkerStart($server, $workerId)); $this->eventDispatch->dispatch(new OnWorkerStart($server, $workerId));
$this->setProcessName(sprintf('Worker[%d].%d', $server->worker_pid, $workerId)); $this->setProcessName(sprintf('Worker[%d].%d', $server->worker_pid, $workerId));
set_env('environmental', Kiri::WORKER); set_env('environmental', Kiri::WORKER);
+3 -18
View File
@@ -65,8 +65,10 @@ class Server extends HttpService
* @throws \ReflectionException * @throws \ReflectionException
* @throws Exception * @throws Exception
*/ */
public function start(): string public function start(): mixed
{ {
$this->configure_set();
$this->manager()->initBaseServer(Config::get('server', [], true), $this->daemon); $this->manager()->initBaseServer(Config::get('server', [], true), $this->daemon);
$rpcService = Config::get('rpc', []); $rpcService = Config::get('rpc', []);
@@ -102,23 +104,6 @@ class Server extends HttpService
} }
/**
* @return void
* @throws ConfigException
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @throws \ReflectionException
* @throws \Exception
*/
public function runtime_start(): void
{
$this->configure_set();
$this->container->get(Router::class)->read_files();
$this->start();
}
/** /**
* @return void * @return void
+1 -40
View File
@@ -77,46 +77,7 @@ class ServerCommand extends Command
return 1; return 1;
} }
} }
$manager->runtime_start(); return $manager->start();
return 0;
}
/**
* @throws ConfigException
*/
private function configure_set()
{
$enable_coroutine = Config::get('servers.settings.enable_coroutine', false);
Config::set('servers.settings.enable_coroutine', true);
if ($enable_coroutine != true) {
return;
}
Coroutine::set([
'hook_flags' => SWOOLE_HOOK_ALL ^ SWOOLE_HOOK_BLOCKING_FUNCTION,
'enable_deadlock_check' => FALSE,
'exit_condition' => function () {
return Coroutine::stats()['coroutine_num'] === 0;
}
]);
}
/**
* @param $manager
* @return int
* @throws ConfigException
* @throws Exception
*/
private function generate_runtime_builder($manager): int
{
$this->configure_set();
Kiri::app()->getRouter()->read_files();
$manager->start();
return 1;
} }
} }