modify
This commit is contained in:
@@ -84,7 +84,7 @@ class Annotation extends Component
|
|||||||
* @param string|null $outPath
|
* @param string|null $outPath
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function instanceDirectoryFiles(string $dir, ?string $outPath = null)
|
public function runtime(string $dir, ?string $outPath = null)
|
||||||
{
|
{
|
||||||
$this->_loader->loadByDirectory($dir, $outPath);
|
$this->_loader->loadByDirectory($dir, $outPath);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,16 +46,16 @@ class OnWorkerStart extends Callback
|
|||||||
$annotation->setLoader($runtime);
|
$annotation->setLoader($runtime);
|
||||||
|
|
||||||
if ($worker_id >= $server->setting['worker_num']) {
|
if ($worker_id >= $server->setting['worker_num']) {
|
||||||
$annotation->instanceDirectoryFiles(MODEL_PATH);
|
$annotation->runtime(MODEL_PATH);
|
||||||
|
|
||||||
$this->onTask($server, $worker_id);
|
$this->onTask($server, $worker_id);
|
||||||
} else {
|
} else {
|
||||||
$start = microtime(true);
|
$start = microtime(true);
|
||||||
|
|
||||||
$annotation->instanceDirectoryFiles($workerDir = realpath(APP_PATH . 'app/Http'));
|
$annotation->runtime($workerDir = directory('app/Http'));
|
||||||
$this->error('use time ' . (microtime(true) - $start));
|
$this->error('use time ' . (microtime(true) - $start));
|
||||||
Coroutine\go(function () use ($annotation, $workerDir) {
|
Coroutine\go(function () use ($annotation, $workerDir) {
|
||||||
$annotation->instanceDirectoryFiles(APP_PATH, $workerDir);
|
$annotation->runtime(directory('app'), $workerDir);
|
||||||
});
|
});
|
||||||
|
|
||||||
$this->onWorker($server, $worker_id);
|
$this->onWorker($server, $worker_id);
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ class Application extends BaseApplication
|
|||||||
$manager->setParameters($argv);
|
$manager->setParameters($argv);
|
||||||
$class = $manager->search();
|
$class = $manager->search();
|
||||||
if (!($class instanceof Command)) {
|
if (!($class instanceof Command)) {
|
||||||
scan_directory(APP_PATH, 'APP');
|
scan_directory(directory('app'), 'App');
|
||||||
}
|
}
|
||||||
response()->send($manager->execCommand($class));
|
response()->send($manager->execCommand($class));
|
||||||
} catch (\Throwable $exception) {
|
} catch (\Throwable $exception) {
|
||||||
|
|||||||
+1
-1
@@ -27,7 +27,7 @@ class Runtime extends Command
|
|||||||
// TODO: Implement onHandler() method.
|
// TODO: Implement onHandler() method.
|
||||||
|
|
||||||
$annotation = Snowflake::app()->getAnnotation();
|
$annotation = Snowflake::app()->getAnnotation();
|
||||||
$annotation->read(APP_PATH, 'App');
|
$annotation->read(directory('app'), 'App');
|
||||||
|
|
||||||
$runtime = storage('runtime.php');
|
$runtime = storage('runtime.php');
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -90,8 +90,9 @@ if (!function_exists('scan_directory')) {
|
|||||||
*/
|
*/
|
||||||
function scan_directory($dir, $namespace)
|
function scan_directory($dir, $namespace)
|
||||||
{
|
{
|
||||||
\annotation()->read($dir, $namespace);
|
$annotation = Snowflake::app()->getAnnotation();
|
||||||
\annotation()->instanceDirectoryFiles($dir);
|
$annotation->read($dir, $namespace);
|
||||||
|
$annotation->runtime($dir, $namespace);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user