diff --git a/HttpServer/Events/OnWorkerStart.php b/HttpServer/Events/OnWorkerStart.php index 2d874fe4..d9d108ea 100644 --- a/HttpServer/Events/OnWorkerStart.php +++ b/HttpServer/Events/OnWorkerStart.php @@ -35,11 +35,10 @@ class OnWorkerStart extends Callback putenv('state=start'); putenv('worker=' . $worker_id); - $attribute = Snowflake::app()->getAttributes(); - $attribute->read(directory('app'), 'App'); - $this->set_process_name($server, $worker_id); + $this->loadDirectory(); + if ($worker_id >= $server->setting['worker_num']) { $this->onTask($server, $worker_id); } else { @@ -48,6 +47,19 @@ class OnWorkerStart extends Callback } + /** + * @throws Exception + */ + private function loadDirectory() + { + if (env('debug','true') === 'false') { + return; + } + $attribute = Snowflake::app()->getAttributes(); + $attribute->read(directory('app'), 'App'); + } + + /** * @param Server $server * @param int $worker_id diff --git a/HttpServer/Server.php b/HttpServer/Server.php index 7d1a0994..7a4e519a 100644 --- a/HttpServer/Server.php +++ b/HttpServer/Server.php @@ -412,7 +412,6 @@ class Server extends HttpService * @return Packet|Websocket|Receive|Http|null * @throws NotFindClassException * @throws ReflectionException - * @throws ComponentException * @throws Exception */ private function onListenerBind($config, $newListener): Packet|Websocket|Receive|Http|null diff --git a/function.php b/function.php index aa9a2275..2995014a 100644 --- a/function.php +++ b/function.php @@ -633,7 +633,7 @@ if (!function_exists('env')) { * @param null $default * @return array|string|null */ - function env($key, $default = null): null|array|string + #[Pure] function env($key, $default = null): null|array|string { $env = getenv($key); if ($env === false) {