diff --git a/Annotation/Annotation.php b/Annotation/Annotation.php index 51bfa598..1dc039b3 100644 --- a/Annotation/Annotation.php +++ b/Annotation/Annotation.php @@ -84,7 +84,7 @@ class Annotation extends Component * @param string|null $outPath * @throws Exception */ - public function instanceDirectoryFiles(string $dir, ?string $outPath = null) + public function runtime(string $dir, ?string $outPath = null) { $this->_loader->loadByDirectory($dir, $outPath); } diff --git a/HttpServer/Events/OnWorkerStart.php b/HttpServer/Events/OnWorkerStart.php index b79afe6f..93ad68ce 100644 --- a/HttpServer/Events/OnWorkerStart.php +++ b/HttpServer/Events/OnWorkerStart.php @@ -46,16 +46,16 @@ class OnWorkerStart extends Callback $annotation->setLoader($runtime); if ($worker_id >= $server->setting['worker_num']) { - $annotation->instanceDirectoryFiles(MODEL_PATH); + $annotation->runtime(MODEL_PATH); $this->onTask($server, $worker_id); } else { $start = microtime(true); - $annotation->instanceDirectoryFiles($workerDir = realpath(APP_PATH . 'app/Http')); + $annotation->runtime($workerDir = directory('app/Http')); $this->error('use time ' . (microtime(true) - $start)); Coroutine\go(function () use ($annotation, $workerDir) { - $annotation->instanceDirectoryFiles(APP_PATH, $workerDir); + $annotation->runtime(directory('app'), $workerDir); }); $this->onWorker($server, $worker_id); diff --git a/System/Application.php b/System/Application.php index 2fe41b8b..fc590f3b 100644 --- a/System/Application.php +++ b/System/Application.php @@ -143,7 +143,7 @@ class Application extends BaseApplication $manager->setParameters($argv); $class = $manager->search(); if (!($class instanceof Command)) { - scan_directory(APP_PATH, 'APP'); + scan_directory(directory('app'), 'App'); } response()->send($manager->execCommand($class)); } catch (\Throwable $exception) { diff --git a/System/Runtime.php b/System/Runtime.php index cf59c651..693902bc 100644 --- a/System/Runtime.php +++ b/System/Runtime.php @@ -27,7 +27,7 @@ class Runtime extends Command // TODO: Implement onHandler() method. $annotation = Snowflake::app()->getAnnotation(); - $annotation->read(APP_PATH, 'App'); + $annotation->read(directory('app'), 'App'); $runtime = storage('runtime.php'); diff --git a/function.php b/function.php index b524832d..c7b03ea9 100644 --- a/function.php +++ b/function.php @@ -90,8 +90,9 @@ if (!function_exists('scan_directory')) { */ function scan_directory($dir, $namespace) { - \annotation()->read($dir, $namespace); - \annotation()->instanceDirectoryFiles($dir); + $annotation = Snowflake::app()->getAnnotation(); + $annotation->read($dir, $namespace); + $annotation->runtime($dir, $namespace); } }