This commit is contained in:
as2252258@163.com
2021-04-09 02:11:48 +08:00
parent 6c20b1b173
commit 54bc7b0b55
5 changed files with 9 additions and 8 deletions
+1 -1
View File
@@ -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);
}
+3 -3
View File
@@ -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);
+1 -1
View File
@@ -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) {
+1 -1
View File
@@ -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');
+3 -2
View File
@@ -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);
}
}