1 files changed, 7 insertions, 11 deletions
diff --git a/src/bundle/Server.ts b/src/bundle/Server.ts
index 91c3dcf4..f743497a 100644
--- a/src/bundle/Server.ts
+++ b/src/bundle/Server.ts
@@ -16,21 +16,18 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-import morgan from "morgan";
-
-process.on("unhandledRejection", console.error);
-process.on("uncaughtException", console.error);
-
import http from "node:http";
+import fs from "node:fs";
+import cluster from "node:cluster";
+import morgan from "morgan";
+import express from "express";
+import { green, bold } from "picocolors";
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";
import { Config, initDatabase } from "@spacebar/util";
-import fs from "node:fs";
-import cluster from "node:cluster";
+import { ProcessLifecycle } from "../util/util/ProcessLifecycle";
const app = express();
const server = http.createServer();
@@ -48,8 +45,7 @@ const webrtc = new Webrtc.Server({
production,
});
-process.on("SIGTERM", async () => {
- console.log("Shutting down due to SIGTERM");
+ProcessLifecycle.eventEmitter.on("stopping", async () => {
await gateway.stop();
await cdn.stop();
await api.stop();
|