add webrtc support (#1284)

Co-authored-by: MaddyUnderStars <46743919+MaddyUnderStars@users.noreply.github.com>
This commit is contained in:
dank074andMaddyUnderStars authored and GitHub committed 2025-06-22 12:41:13 +10:00
1 parent f03c6209a4
commit 526a8da8f5
51 files changed
+1227 -782

No files matched your search

+14 -1
View File
@@ -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";
@@ -30,18 +31,25 @@ import { Config, initDatabase, Sentry } from "@spacebar/util";
const app = express();
const server = http.createServer();
const port = Number(process.env.PORT) || 3001;
const wrtcWsPort = Number(process.env.WRTC_WS_PORT) || 3004;
const production = process.env.NODE_ENV == "development" ? false : true;
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: wrtcWsPort,
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 +62,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);