start adding some abstraction
This commit is contained in:
@@ -22,6 +22,7 @@ process.on("uncaughtException", console.error);
|
||||
import http from "http";
|
||||
import * as Api from "@spacebar/api";
|
||||
import * as Gateway from "@spacebar/gateway";
|
||||
import * as Webrtc from "@spacebar/webrtc";
|
||||
import { CDNServer } from "@spacebar/cdn";
|
||||
import express from "express";
|
||||
import { green, bold } from "picocolors";
|
||||
@@ -36,12 +37,14 @@ server.on("request", app);
|
||||
const api = new Api.SpacebarServer({ server, port, production, app });
|
||||
const cdn = new CDNServer({ server, port, production, app });
|
||||
const gateway = new Gateway.Server({ server, port, production });
|
||||
const webrtc = new Webrtc.Server({ server: undefined, port: 3004, production });
|
||||
|
||||
process.on("SIGTERM", async () => {
|
||||
console.log("Shutting down due to SIGTERM");
|
||||
await gateway.stop();
|
||||
await cdn.stop();
|
||||
await api.stop();
|
||||
await webrtc.stop();
|
||||
server.close();
|
||||
Sentry.close();
|
||||
});
|
||||
@@ -54,7 +57,12 @@ async function main() {
|
||||
await new Promise((resolve) =>
|
||||
server.listen({ port }, () => resolve(undefined)),
|
||||
);
|
||||
await Promise.all([api.start(), cdn.start(), gateway.start()]);
|
||||
await Promise.all([
|
||||
api.start(),
|
||||
cdn.start(),
|
||||
gateway.start(),
|
||||
webrtc.start(),
|
||||
]);
|
||||
|
||||
Sentry.errorHandler(app);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user