From 1cc159348a03550521244cc51154818ec0815ffc Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Tue, 19 Apr 2022 00:57:58 +0200 Subject: Use 1 thread on platform where fetching thread/core count fails --- bundle/scripts/benchmark/connections.js | 7 ++++++- bundle/src/start.ts | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'bundle') diff --git a/bundle/scripts/benchmark/connections.js b/bundle/scripts/benchmark/connections.js index 2a4125b4..ffca2628 100644 --- a/bundle/scripts/benchmark/connections.js +++ b/bundle/scripts/benchmark/connections.js @@ -3,8 +3,13 @@ const cluster = require("cluster"); const WebSocket = require("ws"); const endpoint = process.env.GATEWAY || "ws://localhost:3001"; const connections = Number(process.env.CONNECTIONS) || 50; -const threads = Number(process.env.THREADS) || require("os").cpus().length || 1; const token = process.env.TOKEN; +var cores = 1; +try { + cores = Number(process.env.THREADS) || os.cpus().length; +} catch { + console.log("[Bundle] Failed to get thread count! Using 1...") +} if (!token) { console.error("TOKEN env var missing"); diff --git a/bundle/src/start.ts b/bundle/src/start.ts index 7660b296..de3b5848 100644 --- a/bundle/src/start.ts +++ b/bundle/src/start.ts @@ -9,7 +9,12 @@ config(); import { execSync } from "child_process"; // TODO: add socket event transmission -let cores = Number(process.env.THREADS) || os.cpus().length; +var cores = 1; +try { + cores = Number(process.env.THREADS) || os.cpus().length; +} catch { + console.log("[API] Failed to get thread count! Using 1...") +} if (cluster.isMaster) { function getCommitOrFail() { -- cgit 1.5.1 From 63d9baa1869c5a72a1a086a1304300209cdff708 Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Tue, 19 Apr 2022 01:43:46 +0200 Subject: Try catch cpu log --- bundle/src/stats.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'bundle') diff --git a/bundle/src/stats.ts b/bundle/src/stats.ts index 3c5163c3..0234e0b4 100644 --- a/bundle/src/stats.ts +++ b/bundle/src/stats.ts @@ -4,7 +4,13 @@ import { red } from "picocolors"; export function initStats() { console.log(`[Path] running in ${__dirname}`); - console.log(`[CPU] ${osu.cpu.model()} Cores x${osu.cpu.count()}`); + try { + console.log(`[CPU] ${osu.cpu.model()} Cores x${osu.cpu.count()}`); + } + catch { + console.log('[CPU] Failed to get cpu model!') + } + console.log(`[System] ${os.platform()} ${os.arch()}`); console.log(`[Process] running with PID: ${process.pid}`); if (process.getuid && process.getuid() === 0) { -- cgit 1.5.1 From f09daaa3de902641ca9772089b8af676e05543c3 Mon Sep 17 00:00:00 2001 From: Erkin Alp Güney Date: Thu, 28 Apr 2022 21:38:39 +0300 Subject: needs to be async --- api/src/middlewares/RateLimit.ts | 3 ++- api/src/routes/channels/#channel_id/messages/#message_id/index.ts | 2 +- bundle/package-lock.json | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) (limited to 'bundle') diff --git a/api/src/middlewares/RateLimit.ts b/api/src/middlewares/RateLimit.ts index 7d5c51e2..ca6de98f 100644 --- a/api/src/middlewares/RateLimit.ts +++ b/api/src/middlewares/RateLimit.ts @@ -46,7 +46,8 @@ export default function rateLimit(opts: { }): any { return async (req: Request, res: Response, next: NextFunction): Promise => { // exempt user? if so, immediately short circuit - if (getRights(req.user_id).has("BYPASS_RATE_LIMITS")) return; + const rights = await getRights(req.user_id); + if (rights.has("BYPASS_RATE_LIMITS")) return; const bucket_id = opts.bucket || req.originalUrl.replace(API_PREFIX_TRAILING_SLASH, ""); var executor_id = getIpAdress(req); diff --git a/api/src/routes/channels/#channel_id/messages/#message_id/index.ts b/api/src/routes/channels/#channel_id/messages/#message_id/index.ts index 958954b6..63fee9b9 100644 --- a/api/src/routes/channels/#channel_id/messages/#message_id/index.ts +++ b/api/src/routes/channels/#channel_id/messages/#message_id/index.ts @@ -95,7 +95,7 @@ router.put( var body = req.body as MessageCreateSchema; const attachments: Attachment[] = []; - const rights = getRights(req.user_id); + const rights = await getRights(req.user_id); rights.hasThrow("SEND_MESSAGES"); // regex to check if message contains anything other than numerals ( also no decimals ) diff --git a/bundle/package-lock.json b/bundle/package-lock.json index 4742b4a4..6fbd6978 100644 --- a/bundle/package-lock.json +++ b/bundle/package-lock.json @@ -101,7 +101,7 @@ "name": "@fosscord/api", "version": "1.0.0", "hasInstallScript": true, - "license": "GPLV3", + "license": "AGPLV3", "dependencies": { "@babel/preset-env": "^7.15.8", "@babel/preset-typescript": "^7.15.0", @@ -164,7 +164,7 @@ "../cdn": { "name": "@fosscord/cdn", "version": "1.0.0", - "license": "GPLV3", + "license": "AGPLV3", "dependencies": { "@aws-sdk/client-s3": "^3.36.1", "@aws-sdk/node-http-handler": "^3.36.0", @@ -208,7 +208,7 @@ "name": "@fosscord/gateway", "version": "1.0.0", "hasInstallScript": true, - "license": "GPLV3", + "license": "AGPLV3", "dependencies": { "@fosscord/util": "file:../util", "amqplib": "^0.8.0", -- cgit 1.5.1 From 5adcd70a5171ae807f5fcbcd65eb6a5938c6386a Mon Sep 17 00:00:00 2001 From: KaKi87 Date: Thu, 2 Jun 2022 17:33:50 +0200 Subject: Use SPDX license syntax in 'package.json' files --- api/package.json | 2 +- bundle/package.json | 2 +- cdn/package.json | 2 +- dashboard/package.json | 2 +- gateway/package.json | 2 +- package.json | 2 +- util/package.json | 2 +- webrtc/package.json | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) (limited to 'bundle') diff --git a/api/package.json b/api/package.json index 65472522..29fa82a1 100644 --- a/api/package.json +++ b/api/package.json @@ -30,7 +30,7 @@ "discord-open-source" ], "author": "Fosscord", - "license": "AGPLV3", + "license": "AGPL-3.0-only", "bugs": { "url": "https://github.com/fosscord/fosscord-server/issues" }, diff --git a/bundle/package.json b/bundle/package.json index 7d68427f..d44d257f 100644 --- a/bundle/package.json +++ b/bundle/package.json @@ -18,7 +18,7 @@ }, "keywords": [], "author": "Fosscord", - "license": "AGPLV3", + "license": "AGPL-3.0-only", "bugs": { "url": "https://github.com/fosscord/fosscord-server/issues" }, diff --git a/cdn/package.json b/cdn/package.json index f1d12ba5..46405b88 100644 --- a/cdn/package.json +++ b/cdn/package.json @@ -15,7 +15,7 @@ }, "keywords": [], "author": "Fosscord", - "license": "AGPLV3", + "license": "AGPL-3.0-only", "bugs": { "url": "https://github.com/fosscord/fosscord-server/issues" }, diff --git a/dashboard/package.json b/dashboard/package.json index e71de793..9afe20f8 100644 --- a/dashboard/package.json +++ b/dashboard/package.json @@ -15,7 +15,7 @@ }, "keywords": [], "author": "Fosscord", - "license": "AGPLV3", + "license": "AGPL-3.0-only", "bugs": { "url": "https://github.com/fosscord/fosscord-server/issues" }, diff --git a/gateway/package.json b/gateway/package.json index 92d812b4..7a3b1012 100644 --- a/gateway/package.json +++ b/gateway/package.json @@ -13,7 +13,7 @@ }, "keywords": [], "author": "Fosscord", - "license": "AGPLV3", + "license": "AGPL-3.0-only", "devDependencies": { "@types/amqplib": "^0.8.1", "@types/jsonwebtoken": "^8.5.0", diff --git a/package.json b/package.json index 3395122e..8488ff28 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "url": "git+https://github.com/fosscord/fosscord-server.git" }, "author": "Fosscord", - "license": "AGPLV3", + "license": "AGPL-3.0-only", "bugs": { "url": "https://github.com/fosscord/fosscord-server/issues" }, diff --git a/util/package.json b/util/package.json index 7251d3e4..35d2fbbe 100644 --- a/util/package.json +++ b/util/package.json @@ -23,7 +23,7 @@ "discord-open-source" ], "author": "Fosscord", - "license": "AGPLV3", + "license": "AGPL-3.0-only", "bugs": { "url": "https://github.com/fosscord/fosscord-server/issues" }, diff --git a/webrtc/package.json b/webrtc/package.json index ab9e7486..d973dd7e 100644 --- a/webrtc/package.json +++ b/webrtc/package.json @@ -10,7 +10,7 @@ }, "keywords": [], "author": "Fosscord", - "license": "AGPLV3", + "license": "AGPL-3.0-only", "devDependencies": { "@types/node": "^15.6.1", "@types/ws": "^7.4.4", -- cgit 1.5.1