diff --git a/HttpServer/Events/OnWorkerStart.php b/HttpServer/Events/OnWorkerStart.php index dcd80b32..a661ca0f 100644 --- a/HttpServer/Events/OnWorkerStart.php +++ b/HttpServer/Events/OnWorkerStart.php @@ -33,12 +33,12 @@ class OnWorkerStart extends Callback */ public function onHandler(Server $server, int $worker_id): void { - putenv('worker=' . $worker_id); putenv('state=start'); + putenv('worker=' . $worker_id); - $start = microtime(true); - annotation()->read(APP_PATH . 'app', 'App'); - $this->debug(sprintf('scan app dir use time %s', microtime(true) - $start)); + if (env('debug') === 'true') { + annotation()->read(APP_PATH . 'app', 'App'); + } if ($worker_id >= $server->setting['worker_num']) { $this->onTask($server, $worker_id); diff --git a/HttpServer/Server.php b/HttpServer/Server.php index 361818df..15bf8303 100644 --- a/HttpServer/Server.php +++ b/HttpServer/Server.php @@ -463,10 +463,15 @@ class Server extends HttpService { $event = Snowflake::app()->getEvent(); $event->on(Event::SERVER_WORKER_START, function () { + $annotation = Snowflake::app()->getAttributes(); + if (env('debug') !== 'true') { + return; + } $router = Snowflake::app()->getRouter(); - $router->loadRouterSetting(); - annotation()->instanceDirectoryFiles(CONTROLLER_PATH); + $annotation->instanceDirectoryFiles(CONTROLLER_PATH); + + $router->loadRouterSetting(); }); } @@ -478,7 +483,11 @@ class Server extends HttpService { $event = Snowflake::app()->getEvent(); $event->on(Event::SERVER_WORKER_START, function () { - annotation()->instanceDirectoryFiles(SOCKET_PATH); + $annotation = Snowflake::app()->getAttributes(); + if (env('debug') !== 'true') { + return; + } + $annotation->instanceDirectoryFiles(SOCKET_PATH); }); } diff --git a/System/Application.php b/System/Application.php index e3d783ef..c48de4aa 100644 --- a/System/Application.php +++ b/System/Application.php @@ -109,9 +109,10 @@ class Application extends BaseApplication { try { fire(Event::SERVER_BEFORE_START); - - $this->set('input', $argv); - + if (env('debug') === 'false') { + $annotation = Snowflake::app()->getAttributes(); + $annotation->read(APP_PATH . 'app', 'App'); + } $manager = Snowflake::app()->get('console'); $manager->setParameters($argv); $class = $manager->search(); diff --git a/function.php b/function.php index 63044f1d..e42ac292 100644 --- a/function.php +++ b/function.php @@ -1,6 +1,7 @@