fix bundle
This commit is contained in:
parent
be238a89b9
commit
c3a1740c76
BIN
bundle/database.db
Normal file
BIN
bundle/database.db
Normal file
Binary file not shown.
BIN
bundle/package-lock.json
generated
BIN
bundle/package-lock.json
generated
Binary file not shown.
@ -5,8 +5,9 @@
|
||||
"main": "src/start.js",
|
||||
"scripts": {
|
||||
"preinstall": "cd ../util && npm i && cd ../api && npm i && cd ../cdn && npm i && cd ../gateway && npm i",
|
||||
"build": "npm run build:api && npm run build:cdn && npm run build:gateway && npm run build:bundle",
|
||||
"build": "npm run build:util && npm run build:api && npm run build:cdn && npm run build:gateway && npm run build:bundle",
|
||||
"build:bundle": "npx tsc -b .",
|
||||
"build:util": "cd ../util/ && npm run build",
|
||||
"build:api": "cd ../api/ && npm run build",
|
||||
"build:cdn": "cd ../cdn/ && npm run build",
|
||||
"build:gateway": "cd ../gateway/ && npm run build",
|
||||
|
||||
@ -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