mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-05 05:01:58 +00:00
Allow NUM_WORKERS override (#2776)
Resolves #2610 ## Description: Add NUM_WORKERS env override for server worker count. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced ## Please put your Discord username so you can be contacted if a bug or regression is found: aotumuri --------- Co-authored-by: Evan <evanpelle@gmail.com>
This commit is contained in:
@@ -164,7 +164,17 @@ export abstract class DefaultServerConfig implements ServerConfig {
|
||||
}
|
||||
return token;
|
||||
}
|
||||
abstract numWorkers(): number;
|
||||
numWorkers(): number {
|
||||
const raw = Env.NUM_WORKERS;
|
||||
if (!raw) {
|
||||
throw new Error("NUM_WORKERS not set");
|
||||
}
|
||||
const parsed = Number(raw);
|
||||
if (!Number.isFinite(parsed) || parsed <= 0) {
|
||||
throw new Error(`Invalid NUM_WORKERS value "${raw}"`);
|
||||
}
|
||||
return Math.floor(parsed);
|
||||
}
|
||||
abstract env(): GameEnv;
|
||||
turnIntervalMs(): number {
|
||||
return 100;
|
||||
|
||||
@@ -27,7 +27,6 @@ export class DevServerConfig extends DefaultServerConfig {
|
||||
gameCreationRate(): number {
|
||||
return 5 * 1000;
|
||||
}
|
||||
|
||||
numWorkers(): number {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@@ -89,4 +89,7 @@ export const Env = {
|
||||
get ADMIN_TOKEN() {
|
||||
return getEnv("ADMIN_TOKEN");
|
||||
},
|
||||
get NUM_WORKERS() {
|
||||
return getEnv("NUM_WORKERS");
|
||||
},
|
||||
};
|
||||
|
||||
@@ -5,9 +5,6 @@ export const preprodConfig = new (class extends DefaultServerConfig {
|
||||
env(): GameEnv {
|
||||
return GameEnv.Preprod;
|
||||
}
|
||||
numWorkers(): number {
|
||||
return 2;
|
||||
}
|
||||
turnstileSiteKey(): string {
|
||||
return "0x4AAAAAAB7QetxHwRCKw-aP";
|
||||
}
|
||||
|
||||
@@ -2,9 +2,6 @@ import { GameEnv } from "./Config";
|
||||
import { DefaultServerConfig } from "./DefaultConfig";
|
||||
|
||||
export const prodConfig = new (class extends DefaultServerConfig {
|
||||
numWorkers(): number {
|
||||
return 20;
|
||||
}
|
||||
env(): GameEnv {
|
||||
return GameEnv.Prod;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user