Change bundle start to only start listening once DB and config have been loaded

This commit is contained in:
Madeline 2022-07-10 22:08:42 +10:00
parent 3f59a5b529
commit 3e47da130c

View File

@ -33,7 +33,6 @@ process.on('SIGTERM', () => {
//this is what has been added for the /stop API route //this is what has been added for the /stop API route
async function main() { async function main() {
server.listen(port);
await initDatabase(); await initDatabase();
await Config.init(); await Config.init();
// only set endpointPublic, if not already set // only set endpointPublic, if not already set
@ -84,7 +83,7 @@ async function main() {
app.use(Sentry.Handlers.requestHandler()); app.use(Sentry.Handlers.requestHandler());
app.use(Sentry.Handlers.tracingHandler()); app.use(Sentry.Handlers.tracingHandler());
} }
await Promise.all([api.start(), cdn.start(), gateway.start()]);
if (Config.get().sentry.enabled) { if (Config.get().sentry.enabled) {
app.use(Sentry.Handlers.errorHandler()); app.use(Sentry.Handlers.errorHandler());
app.use(function onError(err: any, req: any, res: any, next: any) { app.use(function onError(err: any, req: any, res: any, next: any) {
@ -92,6 +91,8 @@ async function main() {
res.end(res.sentry + "\n"); res.end(res.sentry + "\n");
}); });
} }
await Promise.all([api.start(), cdn.start(), gateway.start()]);
console.log(`[Server] ${green(`listening on port ${bold(port)}`)}`); console.log(`[Server] ${green(`listening on port ${bold(port)}`)}`);
} }