Skip to content

Commit

Permalink
feat: optimize route handle
Browse files Browse the repository at this point in the history
  • Loading branch information
bingcool committed Aug 31, 2023
1 parent 0f5d760 commit b922d23
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/Core/BaseServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ public function __construct()
protected function workerStartInit($server, $workerId)
{
try {
// 加载路由文件
if (self::isHttpApp() && self::isWorkerProcess($workerId) && !SystemEnv::isWorkerService()) {
Route::loadRouteFile();
}
// global server
Swfy::setSwooleServer($server);
// global conf
Expand All @@ -195,10 +199,7 @@ protected function workerStartInit($server, $workerId)
self::startInclude();
// 记录worker的进程worker_pid与worker_id的映射
self::setWorkersPid($workerId, $server->worker_pid);
// 加载路由文件
if (self::isHttpApp() && self::isWorkerProcess($workerId) && !SystemEnv::isWorkerService()) {
Route::loadRouteFile();
}

}catch(\Throwable $throwable) {
self::catchException($throwable);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Core/HttpRoute.php
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ protected static function getHttpRouterMapUri(string $uri): array
return $routeCache;

}else {
throw new DispatchException('Not Found Route.');
throw new DispatchException("Not Found Route [$uri].");
}
}

Expand Down

0 comments on commit b922d23

Please sign in to comment.