mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-10 20:52:42 +01:00
Rainbow the logs
This commit is contained in:
parent
e52e7ef0e1
commit
d4ddf3acf0
37
bundle/package-lock.json
generated
37
bundle/package-lock.json
generated
@ -15,6 +15,7 @@
|
||||
"@fosscord/gateway": "file:../gateway",
|
||||
"@fosscord/util": "file:../util",
|
||||
"async-exit-hook": "^2.0.1",
|
||||
"chalk": "^4.1.2",
|
||||
"express": "^4.17.1",
|
||||
"missing-native-js-functions": "^1.2.15",
|
||||
"node-os-utils": "^1.3.5",
|
||||
@ -31,7 +32,7 @@
|
||||
"@types/mongoose-autopopulate": "^0.10.1",
|
||||
"@types/mongoose-lean-virtuals": "^0.5.1",
|
||||
"@types/multer": "^1.4.5",
|
||||
"@types/node": "^14.17.9",
|
||||
"@types/node": "^14.17.20",
|
||||
"@types/node-fetch": "^2.5.7",
|
||||
"@types/node-os-utils": "^1.2.0",
|
||||
"@types/uuid": "^8.3.0",
|
||||
@ -195,6 +196,9 @@
|
||||
"ts-node-dev": "^1.1.6",
|
||||
"ts-patch": "^1.4.4",
|
||||
"typescript": "^4.2.3"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@yukikaze-bot/erlpack": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"../util": {
|
||||
@ -465,9 +469,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "14.17.16",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.17.16.tgz",
|
||||
"integrity": "sha512-WiFf2izl01P1CpeY8WqFAeKWwByMueBEkND38EcN8N68qb0aDG3oIS1P5MhAX5kUdr469qRyqsY/MjanLjsFbQ==",
|
||||
"version": "14.17.20",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.17.20.tgz",
|
||||
"integrity": "sha512-gI5Sl30tmhXsqkNvopFydP7ASc4c2cLfGNQrVKN3X90ADFWFsPEsotm/8JHSUJQKTHbwowAHtcJPeyVhtKv0TQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/node-fetch": {
|
||||
@ -593,7 +597,6 @@
|
||||
"version": "4.3.0",
|
||||
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
|
||||
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"color-convert": "^2.0.1"
|
||||
},
|
||||
@ -733,7 +736,6 @@
|
||||
"version": "4.1.2",
|
||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
|
||||
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"ansi-styles": "^4.1.0",
|
||||
"supports-color": "^7.1.0"
|
||||
@ -749,7 +751,6 @@
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
|
||||
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"color-name": "~1.1.4"
|
||||
},
|
||||
@ -760,8 +761,7 @@
|
||||
"node_modules/color-name": {
|
||||
"version": "1.1.4",
|
||||
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
|
||||
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
|
||||
"dev": true
|
||||
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
|
||||
},
|
||||
"node_modules/combined-stream": {
|
||||
"version": "1.0.8",
|
||||
@ -1033,7 +1033,6 @@
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
|
||||
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
@ -1493,7 +1492,6 @@
|
||||
"version": "7.2.0",
|
||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
|
||||
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"has-flag": "^4.0.0"
|
||||
},
|
||||
@ -1810,6 +1808,7 @@
|
||||
"@types/node-fetch": "^2.5.12",
|
||||
"@types/uuid": "^8.3.0",
|
||||
"@types/ws": "^7.4.0",
|
||||
"@yukikaze-bot/erlpack": "^1.0.1",
|
||||
"@zerollup/ts-transform-paths": "^1.7.18",
|
||||
"ajv": "^8.5.0",
|
||||
"amqplib": "^0.8.0",
|
||||
@ -2040,9 +2039,9 @@
|
||||
}
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "14.17.16",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.17.16.tgz",
|
||||
"integrity": "sha512-WiFf2izl01P1CpeY8WqFAeKWwByMueBEkND38EcN8N68qb0aDG3oIS1P5MhAX5kUdr469qRyqsY/MjanLjsFbQ==",
|
||||
"version": "14.17.20",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.17.20.tgz",
|
||||
"integrity": "sha512-gI5Sl30tmhXsqkNvopFydP7ASc4c2cLfGNQrVKN3X90ADFWFsPEsotm/8JHSUJQKTHbwowAHtcJPeyVhtKv0TQ==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/node-fetch": {
|
||||
@ -2147,7 +2146,6 @@
|
||||
"version": "4.3.0",
|
||||
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
|
||||
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"color-convert": "^2.0.1"
|
||||
}
|
||||
@ -2241,7 +2239,6 @@
|
||||
"version": "4.1.2",
|
||||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
|
||||
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ansi-styles": "^4.1.0",
|
||||
"supports-color": "^7.1.0"
|
||||
@ -2251,7 +2248,6 @@
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
|
||||
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"color-name": "~1.1.4"
|
||||
}
|
||||
@ -2259,8 +2255,7 @@
|
||||
"color-name": {
|
||||
"version": "1.1.4",
|
||||
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
|
||||
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
|
||||
"dev": true
|
||||
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
|
||||
},
|
||||
"combined-stream": {
|
||||
"version": "1.0.8",
|
||||
@ -2477,8 +2472,7 @@
|
||||
"has-flag": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
|
||||
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
|
||||
"dev": true
|
||||
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ=="
|
||||
},
|
||||
"http-errors": {
|
||||
"version": "1.7.2",
|
||||
@ -2830,7 +2824,6 @@
|
||||
"version": "7.2.0",
|
||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
|
||||
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"has-flag": "^4.0.0"
|
||||
}
|
||||
|
@ -38,7 +38,7 @@
|
||||
"@types/mongoose-autopopulate": "^0.10.1",
|
||||
"@types/mongoose-lean-virtuals": "^0.5.1",
|
||||
"@types/multer": "^1.4.5",
|
||||
"@types/node": "^14.17.9",
|
||||
"@types/node": "^14.17.20",
|
||||
"@types/node-fetch": "^2.5.7",
|
||||
"@types/node-os-utils": "^1.2.0",
|
||||
"@types/uuid": "^8.3.0",
|
||||
@ -54,6 +54,7 @@
|
||||
"@fosscord/gateway": "file:../gateway",
|
||||
"@fosscord/util": "file:../util",
|
||||
"async-exit-hook": "^2.0.1",
|
||||
"chalk": "^4.1.2",
|
||||
"express": "^4.17.1",
|
||||
"missing-native-js-functions": "^1.2.15",
|
||||
"node-os-utils": "^1.3.5",
|
||||
|
@ -6,6 +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 { red, green, bold } from "chalk";
|
||||
import { Config, initDatabase } from "@fosscord/util";
|
||||
|
||||
const app = express();
|
||||
@ -58,7 +59,7 @@ async function main() {
|
||||
} as any);
|
||||
|
||||
await Promise.all([api.start(), cdn.start(), gateway.start()]);
|
||||
console.log(`[Server] listening on port ${port}`);
|
||||
console.log(`[Server] ${green(`listening on port ${bold(port)}`)}`);
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
|
@ -1,10 +1,28 @@
|
||||
// process.env.MONGOMS_DEBUG = "true";
|
||||
import cluster from "cluster";
|
||||
import os from "os";
|
||||
import { red, bold, yellow, cyan } from "chalk";
|
||||
import { initStats } from "./stats";
|
||||
|
||||
// TODO: add tcp socket event transmission
|
||||
const cores = 1 || Number(process.env.threads) || os.cpus().length;
|
||||
const commit = require('child_process').execSync('git rev-parse HEAD').toString().trim();
|
||||
|
||||
console.log(bold(`
|
||||
███████ ██████ ███████ ███████ ██████ ██████ ██████ ██████
|
||||
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
|
||||
█████ ██ ██ ███████ ███████ ██ ██ ██ ██████ ██ ██
|
||||
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
|
||||
██ ██████ ███████ ███████ ██████ ██████ ██ ██ ██████
|
||||
|
||||
|
||||
fosscord-server | ${yellow(`Pre-relase (${commit.slice(0, 7)})`)}
|
||||
|
||||
Current commit: ${cyan(commit)} (${yellow(commit.slice(0, 7))})
|
||||
`))
|
||||
|
||||
|
||||
|
||||
|
||||
if (cluster.isMaster && !process.env.masterStarted) {
|
||||
process.env.masterStarted = "true";
|
||||
@ -24,7 +42,7 @@ if (cluster.isMaster && !process.env.masterStarted) {
|
||||
|
||||
cluster.on("exit", (worker: any, code: any, signal: any) => {
|
||||
console.log(
|
||||
`[Worker] died with pid: ${worker.process.pid} , restarting ...`
|
||||
`[Worker] ${red(`died with pid: ${worker.process.pid} , restarting ...`)}`
|
||||
);
|
||||
cluster.fork();
|
||||
});
|
||||
|
@ -1,5 +1,6 @@
|
||||
import os from "os";
|
||||
import osu from "node-os-utils";
|
||||
import {} from "chalk";
|
||||
|
||||
export function initStats() {
|
||||
console.log(`[Path] running in ${__dirname}`);
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { FileStorage } from "./FileStorage";
|
||||
import path from "path";
|
||||
import fse from "fs-extra";
|
||||
import { bgCyan, black } from "chalk";
|
||||
process.cwd();
|
||||
|
||||
export interface Storage {
|
||||
@ -18,7 +19,7 @@ if (process.env.STORAGE_PROVIDER === "file" || !process.env.STORAGE_PROVIDER) {
|
||||
} else {
|
||||
location = path.join(process.cwd(), "files");
|
||||
}
|
||||
console.log(`[CDN] storage location: ${location}`);
|
||||
console.log(`[CDN] storage location: ${bgCyan(`${black(location)}`)}`);
|
||||
fse.ensureDirSync(location);
|
||||
process.env.STORAGE_LOCATION = location;
|
||||
|
||||
|
1
util/package-lock.json
generated
1
util/package-lock.json
generated
@ -12,6 +12,7 @@
|
||||
"dependencies": {
|
||||
"ajv": "^8.6.2",
|
||||
"amqplib": "^0.8.0",
|
||||
"chalk": "^4.1.2",
|
||||
"class-validator": "^0.13.1",
|
||||
"dot-prop": "^6.0.1",
|
||||
"env-paths": "^2.2.1",
|
||||
|
@ -39,6 +39,7 @@
|
||||
"dependencies": {
|
||||
"ajv": "^8.6.2",
|
||||
"amqplib": "^0.8.0",
|
||||
"chalk": "^4.1.2",
|
||||
"class-validator": "^0.13.1",
|
||||
"dot-prop": "^6.0.1",
|
||||
"env-paths": "^2.2.1",
|
||||
|
@ -2,6 +2,7 @@ import path from "path";
|
||||
import "reflect-metadata";
|
||||
import { Connection, createConnection, ValueTransformer } from "typeorm";
|
||||
import * as Models from "../entities";
|
||||
import { yellow, green} from "chalk";
|
||||
|
||||
// UUID extension option is only supported with postgres
|
||||
// We want to generate all id's with Snowflakes that's why we have our own BaseEntity class
|
||||
@ -12,7 +13,7 @@ var dbConnection: Connection | undefined;
|
||||
export function initDatabase() {
|
||||
if (promise) return promise; // prevent initalizing multiple times
|
||||
|
||||
console.log("[Database] connecting ...");
|
||||
console.log(`[Database] ${yellow("connecting ...")}`);
|
||||
// @ts-ignore
|
||||
promise = createConnection({
|
||||
type: "sqlite",
|
||||
@ -32,7 +33,7 @@ export function initDatabase() {
|
||||
|
||||
promise.then((connection) => {
|
||||
dbConnection = connection;
|
||||
console.log("[Database] connected");
|
||||
console.log(`[Database] ${green("connected")}`);
|
||||
});
|
||||
|
||||
return promise;
|
||||
|
Loading…
Reference in New Issue
Block a user