summary refs log tree commit diff
path: root/src/Server.ts
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-08-30 15:13:18 +1000
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-08-30 15:13:18 +1000
commitc2931f61aa0adb682ab023d85ba599099024d62b (patch)
tree86de9071cbded565fe9e082bd2cc6c611a926c6c /src/Server.ts
parentGuild join messages (diff)
parentOop, deprecated typeorm call (diff)
downloadserver-c2931f61aa0adb682ab023d85ba599099024d62b.tar.xz
Merge branch 'staging' into dev/Maddy/feat/welcomeMessages
Diffstat (limited to '')
-rw-r--r--src/Server.ts (renamed from bundle/src/Server.ts)61
1 files changed, 15 insertions, 46 deletions
diff --git a/bundle/src/Server.ts b/src/Server.ts

index 71a60d49..83e16fa6 100644 --- a/bundle/src/Server.ts +++ b/src/Server.ts
@@ -1,15 +1,16 @@ process.on("unhandledRejection", console.error); process.on("uncaughtException", console.error); -import http from "http"; import * as Api from "@fosscord/api"; -import * as Gateway from "@fosscord/gateway"; import { CDNServer } from "@fosscord/cdn"; -import express from "express"; -import { green, bold, yellow } from "picocolors"; -import { Config, initDatabase } from "@fosscord/util"; +import * as Gateway from "@fosscord/gateway"; +import { Config, getOrInitialiseDatabase } from "@fosscord/util"; import * as Sentry from "@sentry/node"; import * as Tracing from "@sentry/tracing"; +import express from "express"; +import http from "http"; +import { bold, green, yellow } from "picocolors"; +// import { PluginLoader } from "@fosscord/util"; const app = express(); const server = http.createServer(); @@ -25,58 +26,25 @@ const cdn = new CDNServer({ server, port, production, app }); const gateway = new Gateway.Server({ server, port, production }); //this is what has been added for the /stop API route -process.on('SIGTERM', () => { +process.on("SIGTERM", () => { + setTimeout(() => process.exit(0), 3000); server.close(() => { - console.log("Stop API has been successfully POSTed, SIGTERM sent") - }) -}) + console.log("Stop API has been successfully POSTed, SIGTERM sent"); + }); +}); //this is what has been added for the /stop API route async function main() { server.listen(port); - await initDatabase(); + await getOrInitialiseDatabase(); await Config.init(); - // only set endpointPublic, if not already set - await Config.set({ - cdn: { - endpointClient: "${location.host}", - endpointPrivate: `http://localhost:${port}`, - }, - gateway: { - endpointClient: - '${location.protocol === "https:" ? "wss://" : "ws://"}${location.host}', - endpointPrivate: `ws://localhost:${port}`, - ...(!Config.get().gateway.endpointPublic && { - endpointPublic: `ws://localhost:${port}`, - }), - }, - // regions: { - // default: "fosscord", - // useDefaultAsOptimal: true, - // available: [ - // { - // id: "fosscord", - // name: "Fosscord", - // endpoint: "127.0.0.1:3001", - // vip: false, - // custom: false, - // deprecated: false, - // }, - // ], - // }, - } as any); //Sentry if (Config.get().sentry.enabled) { - console.log( - `[Bundle] ${yellow("You are using Sentry! This may slightly impact performance on large loads!")}` - ); + console.log(`[Bundle] ${yellow("You are using Sentry! This may slightly impact performance on large loads!")}`); Sentry.init({ dsn: Config.get().sentry.endpoint, - integrations: [ - new Sentry.Integrations.Http({ tracing: true }), - new Tracing.Integrations.Express({ app }), - ], + integrations: [new Sentry.Integrations.Http({ tracing: true }), new Tracing.Integrations.Express({ app })], tracesSampleRate: Config.get().sentry.traceSampleRate, environment: Config.get().sentry.environment }); @@ -93,6 +61,7 @@ async function main() { }); } console.log(`[Server] ${green(`listening on port ${bold(port)}`)}`); + // PluginLoader.loadPlugins(); } main().catch(console.error);