diff options
author | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-08-15 21:56:30 +0200 |
---|---|---|
committer | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-08-15 21:56:30 +0200 |
commit | dbdfbf61f29f6e454c0543c977afb4061d24afa8 (patch) | |
tree | 25f6ca9692eeda3cdb6657aec0b4ee87c1acdedb /bundle/src | |
parent | :bug: prevent @everyone role deletion (diff) | |
download | server-dbdfbf61f29f6e454c0543c977afb4061d24afa8.tar.xz |
:bug: fix server bundle
Diffstat (limited to 'bundle/src')
-rw-r--r-- | bundle/src/BundledServer.ts | 41 | ||||
-rw-r--r-- | bundle/src/Database.ts | 2 | ||||
-rw-r--r-- | bundle/src/Server.ts | 24 | ||||
-rw-r--r-- | bundle/src/stats.ts | 2 |
4 files changed, 18 insertions, 51 deletions
diff --git a/bundle/src/BundledServer.ts b/bundle/src/BundledServer.ts deleted file mode 100644 index 6951c1c4..00000000 --- a/bundle/src/BundledServer.ts +++ /dev/null @@ -1,41 +0,0 @@ -process.on("unhandledRejection", console.error); -process.on("uncaughtException", console.error); - -import http from "http"; -import { FosscordServer as APIServer } from "@fosscord/api"; -import { Server as GatewayServer } from "@fosscord/gateway"; -import { CDNServer } from "@fosscord/cdn/"; -import express from "express"; -import { Config } from "../../util/dist"; - -const app = express(); -const server = http.createServer(); -const port = Number(process.env.PORT) || 8080; -const production = true; -server.on("request", app); - -// @ts-ignore -const api = new APIServer({ server, port, production, app }); -// @ts-ignore -const cdn = new CDNServer({ server, port, production, app }); -// @ts-ignore -const gateway = new GatewayServer({ server, port, production }); - -async function main() { - await Config.set({ - cdn: { - endpointClient: "${location.host}", - endpoint: `http://localhost:${port}`, - }, - gateway: { - endpointClient: '${location.protocol === "https:" ? "wss://" : "ws://"}${location.host}', - endpoint: `ws://localhost:${port}`, - }, - }); - - await api.start(); - await cdn.start(); - await gateway.start(); -} - -main().catch(console.error); diff --git a/bundle/src/Database.ts b/bundle/src/Database.ts index 0efd2471..7351290a 100644 --- a/bundle/src/Database.ts +++ b/bundle/src/Database.ts @@ -2,7 +2,7 @@ import fs from "fs"; import { MongoMemoryServer } from "mongodb-memory-server"; import path from "path"; import exitHook from "async-exit-hook"; -console.log(process.arch, process.platform); + if (process.arch == "ia32") { Object.defineProperty(process, "arch", { value: "x64", diff --git a/bundle/src/Server.ts b/bundle/src/Server.ts index 42a3f3c3..0ef7a8a3 100644 --- a/bundle/src/Server.ts +++ b/bundle/src/Server.ts @@ -1,27 +1,35 @@ process.on("unhandledRejection", console.error); process.on("uncaughtException", console.error); +import http from "http"; import { FosscordServer as APIServer } from "@fosscord/api"; import { Server as GatewayServer } from "@fosscord/gateway"; import { CDNServer } from "@fosscord/cdn/"; +import express from "express"; import { Config } from "../../util/dist"; -const production = true; +const app = express(); +const server = http.createServer(); +const port = Number(process.env.PORT) || 8080; +const production = false; +server.on("request", app); -const api = new APIServer({ production, port: Number(process.env.API_PORT) || 3001 }); -const gateway = new GatewayServer({ port: Number(process.env.GATEWAY_PORT) || 3002 }); -const cdn = new CDNServer({ production, port: Number(process.env.CDN_PORT) || 3003 }); +// @ts-ignore +const api = new APIServer({ server, port, production, app }); +// @ts-ignore +const cdn = new CDNServer({ server, port, production, app }); +// @ts-ignore +const gateway = new GatewayServer({ server, port, production }); async function main() { await Config.set({ cdn: { endpointClient: "${location.host}", - endpoint: `http://localhost:${cdn.options.port}`, + endpoint: `http://localhost:${port}`, }, gateway: { - endpointClient: - '${location.protocol === "https:" ? "wss://" : "ws://"}${location.hostname}:' + gateway.port, - endpoint: `ws://localhost:${gateway.port}`, + endpointClient: '${location.protocol === "https:" ? "wss://" : "ws://"}${location.host}', + endpoint: `ws://localhost:${port}`, }, }); diff --git a/bundle/src/stats.ts b/bundle/src/stats.ts index c621ed75..0a10a855 100644 --- a/bundle/src/stats.ts +++ b/bundle/src/stats.ts @@ -18,5 +18,5 @@ export function initStats() { process.memoryUsage().rss / 1024 / 1024 )}mb/${memory.totalMemMb.toFixed(0)}mb` ); - }, 1000 * 60); + }, 1000 * 30); } |