42 lines
1.4 KiB
TypeScript
42 lines
1.4 KiB
TypeScript
import { aimeDbServerFactory, allnetServer, titleServer } from "./servers/index";
|
|
import { AppDataSource } from "external/db/data-source";
|
|
import CreateLogCtx from "lib/logger/logger";
|
|
import { Config } from "lib/setup/config";
|
|
import net from "net";
|
|
import "reflect-metadata";
|
|
|
|
const logger = CreateLogCtx(__filename);
|
|
|
|
logger.info(`Booting ${Config.NAME}.`, { bootInfo: true });
|
|
logger.info(`Log level is set to ${Config.LOGGER_CONFIG.LOG_LEVEL}.`, { bootInfo: true });
|
|
|
|
const start = process.hrtime.bigint();
|
|
|
|
logger.info("Initializing database connection...");
|
|
void AppDataSource.initialize().then(() => {
|
|
const end = process.hrtime.bigint();
|
|
|
|
logger.info(`Database connected in ${(end - start) / 1000000n}ms`);
|
|
|
|
if (Config.ALLNET_CONFIG.ENABLED) {
|
|
logger.info(
|
|
`Starting ALL.Net server on ${Config.LISTEN_ADDRESS}:${Config.ALLNET_CONFIG.PORT}.`
|
|
);
|
|
allnetServer.listen(Config.ALLNET_CONFIG.PORT, Config.LISTEN_ADDRESS);
|
|
}
|
|
|
|
if (Config.TITLES_CONFIG.ENABLED) {
|
|
logger.info(
|
|
`Starting title server on ${Config.LISTEN_ADDRESS}:${Config.ALLNET_CONFIG.PORT}.`
|
|
);
|
|
titleServer.listen(Config.TITLES_CONFIG.PORT, Config.LISTEN_ADDRESS);
|
|
}
|
|
|
|
if (Config.AIMEDB_CONFIG.ENABLED) {
|
|
const server = net.createServer(aimeDbServerFactory());
|
|
|
|
logger.info(`Starting AimeDB on ${Config.LISTEN_ADDRESS}:${Config.ALLNET_CONFIG.PORT}.`);
|
|
server.listen(Config.AIMEDB_CONFIG.PORT, Config.LISTEN_ADDRESS);
|
|
}
|
|
});
|