mirror of
https://github.com/spacebarchat/server.git
synced 2026-10-23 23:53:15 +00:00
fix bundle
This commit is contained in:
1 parent
be238a89b9
commit
c3a1740c76
6 files changed
+5
-48
No files matched your search
@@ -1,44 +0,0 @@
|
||||
import fs from "fs";
|
||||
import { MongoMemoryServer } from "mongodb-memory-server";
|
||||
import path from "path";
|
||||
import exitHook from "async-exit-hook";
|
||||
|
||||
if (process.arch == "ia32") {
|
||||
Object.defineProperty(process, "arch", {
|
||||
value: "x64",
|
||||
});
|
||||
}
|
||||
|
||||
export async function setupDatabase() {
|
||||
if (process.env.MONGO_URL) return; // exit because the user provides his own mongodb
|
||||
const dbPath = path.join(__dirname, "..", "..", "db");
|
||||
const dbName = "fosscord";
|
||||
const storageEngine = "wiredTiger";
|
||||
const port = 27020;
|
||||
const ip = "127.0.0.1";
|
||||
var mongod: MongoMemoryServer;
|
||||
fs.mkdirSync(dbPath, { recursive: true });
|
||||
|
||||
exitHook((callback: any) => {
|
||||
(async () => {
|
||||
console.log(`Stopping MongoDB ...`);
|
||||
await mongod.stop();
|
||||
console.log(`Stopped MongoDB`);
|
||||
callback();
|
||||
})();
|
||||
});
|
||||
|
||||
console.log(`[Database] starting ...`);
|
||||
mongod = new MongoMemoryServer({
|
||||
instance: {
|
||||
port,
|
||||
ip,
|
||||
dbName,
|
||||
dbPath,
|
||||
storageEngine,
|
||||
auth: false, // by default `mongod` is started with '--noauth', start `mongod` with '--auth'
|
||||
},
|
||||
});
|
||||
await mongod.start();
|
||||
process.env.MONGO_URL = mongod.getUri(dbName);
|
||||
}
|
||||
@@ -6,7 +6,7 @@ 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 "@fosscord/util";
|
||||
import { Config, initDatabase } from "@fosscord/util";
|
||||
|
||||
const app = express();
|
||||
const server = http.createServer();
|
||||
@@ -22,6 +22,8 @@ const cdn = new CDNServer({ server, port, production, app });
|
||||
const gateway = new GatewayServer({ server, port, production });
|
||||
|
||||
async function main() {
|
||||
await initDatabase();
|
||||
await Config.init();
|
||||
await Config.set({
|
||||
cdn: {
|
||||
endpointClient: "${location.host}",
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// process.env.MONGOMS_DEBUG = "true";
|
||||
import cluster from "cluster";
|
||||
import os from "os";
|
||||
import { setupDatabase } from "./Database";
|
||||
import { initStats } from "./stats";
|
||||
|
||||
// TODO: add tcp socket event transmission
|
||||
@@ -12,7 +11,6 @@ if (cluster.isMaster && !process.env.masterStarted) {
|
||||
|
||||
(async () => {
|
||||
initStats();
|
||||
await setupDatabase();
|
||||
|
||||
if (cores === 1) {
|
||||
require("./Server.js");
|
||||
|
||||
Reference in new issue
Block a user