Process lifecycle scripts

#Conflicts:
#	src/api/Server.ts
#	src/bundle/Server.ts
#	src/cdn/Server.ts
#	src/gateway/Server.ts
#	src/gateway/events/Connection.ts
#	src/util/util/ipc/listener/RabbitMqSingleListener.ts
#	src/util/util/ipc/listener/UnixSocketListener.ts
#	src/util/util/ipc/writer/UnixSocketWriter.ts
#	src/webrtc/Server.ts
This commit is contained in:
Rory&
2026-05-28 10:38:39 +02:00
parent ac3160e833
commit b1b73d45e7
16 changed files with 181 additions and 95 deletions
+7 -11
View File
@@ -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();