Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow customizing some of the server options #16

Merged
merged 4 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,13 @@ mods:
- screepsmod-mongo
bots:
simplebot: screepsbot-zeswarm

serverOptions:
# The number of parallel runner threads in which player scripts are executed.
# Don't set this option greater than the number of your physical CPU cores.
runnerThreads: 4
# The number of room processor worker processes to launch.
# Don't set this option greater than the number of your physical CPU cores.
processorsCnt: 2
# If set, forward console messages to terminal
logConsole: false
29 changes: 22 additions & 7 deletions screeps-start.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,33 @@ const writeModsConfiguration = () => {
console.log("Mods have been configured");
};

// Map from camelCase to snake_case
const ServerConfigMap = {
runnersThreads: "runner_threads",
processorsCnt: "processors_cnt",
storageTimeout: "storage_timeout",
logConsole: "log_console",
logRotateKeep: "log_rotate_keep",
restartInterval: "restart_interval",
};

const start = async () => {
installPackages();
writeModsConfiguration();

const screeps = require("@screeps/launcher");
await screeps.start(
{
steam_api_key: process.env.STEAM_KEY || config.steamKey,
storage_disable: false,
},
process.stdout,
);
const options = {
steam_api_key: process.env.STEAM_KEY || config.steamKey,
storage_disable: false,
};

for (const [configKey, optionsKey] of Object.entries(ServerConfigMap)) {
if (configKey in config.serverOptions) {
options[optionsKey] = config.serverOptions[key];
}
}

await screeps.start(options, process.stdout);
};

start().catch((err) => {
Expand Down
Loading