Don't build the routing tree until absolutely necessary.

Saves us a lot of time and memory in case of an error.
This commit is contained in:
Jordan Bancino 2023-04-20 17:37:18 +00:00
parent 4a5c7480aa
commit 19b0dcac5a

View file

@ -237,15 +237,6 @@ start:
Log(LOG_DEBUG, "Opened database."); Log(LOG_DEBUG, "Opened database.");
} }
Log(LOG_NOTICE, "Building routing tree...");
matrixArgs.router = RouterBuild();
if (!matrixArgs.router)
{
Log(LOG_ERR, "Unable to build routing tree.");
exit = EXIT_FAILURE;
goto finish;
}
if (!ConfigExists(matrixArgs.db)) if (!ConfigExists(matrixArgs.db))
{ {
char *token; char *token;
@ -525,6 +516,15 @@ start:
Log(LOG_NOTICE, "Starting job scheduler..."); Log(LOG_NOTICE, "Starting job scheduler...");
CronStart(cron); CronStart(cron);
Log(LOG_NOTICE, "Building routing tree...");
matrixArgs.router = RouterBuild();
if (!matrixArgs.router)
{
Log(LOG_ERR, "Unable to build routing tree.");
exit = EXIT_FAILURE;
goto finish;
}
Log(LOG_NOTICE, "Starting server..."); Log(LOG_NOTICE, "Starting server...");
for (i = 0; i < ArraySize(httpServers); i++) for (i = 0; i < ArraySize(httpServers); i++)