This commit is contained in:
2021-08-05 17:06:38 +08:00
parent f0eb29fbd5
commit 395be286f8
+6 -9
View File
@@ -46,31 +46,28 @@ class OnServerWorker extends \Server\Abstracts\Server
{ {
$this->_setConfigCache($workerId); $this->_setConfigCache($workerId);
$annotation = Snowflake::app()->getAnnotation(); $annotation = Snowflake::app()->getAnnotation();
$annotation->read(APP_PATH . 'app'); $annotation->read(APP_PATH . 'app', 'App',
$workerId < $server->setting['worker_num'] ? [] : [CONTROLLER_PATH]
);
$this->eventDispatch->dispatch(new OnWorkerStart($server, $workerId)); $this->eventDispatch->dispatch(new OnWorkerStart($server, $workerId));
$this->runEvent(Constant::WORKER_START, null, [$server, $workerId]); $this->runEvent(Constant::WORKER_START, null, [$server, $workerId]);
$this->workerInitExecutor($server, $annotation, $workerId); $this->workerInitExecutor($server, $annotation, $workerId);
$this->interpretDirectory($server, $annotation, $workerId); $this->interpretDirectory($annotation);
} }
/** /**
* @param Server $server
* @param Annotation $annotation * @param Annotation $annotation
* @param $workerId
* @throws NotFindClassException * @throws NotFindClassException
* @throws ReflectionException * @throws ReflectionException
* @throws Exception * @throws Exception
*/ */
private function interpretDirectory(Server $server, Annotation $annotation, $workerId) private function interpretDirectory(Annotation $annotation)
{ {
$fileLists = $annotation->runtime(APP_PATH . 'app', $fileLists = $annotation->runtime(APP_PATH . 'app');
$workerId < $server->setting['worker_num'] ? [] : [CONTROLLER_PATH]
);
$di = Snowflake::getDi(); $di = Snowflake::getDi();
foreach ($fileLists as $class) { foreach ($fileLists as $class) {
$instance = $di->get($class); $instance = $di->get($class);