Skip to content

Commit

Permalink
fix runners count and add defaults to use all cores
Browse files Browse the repository at this point in the history
  • Loading branch information
Jomik committed Jan 30, 2024
1 parent 5306590 commit 1954702
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
6 changes: 0 additions & 6 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,5 @@ 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
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ version: "3"
services:
screeps:
platform: linux/x86_64
image: jomik/screeps-server:edge
# image: jomik/screeps-server:edge
build: .
depends_on:
- mongo
- redis
Expand Down
12 changes: 10 additions & 2 deletions screeps-start.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#! /usr/bin/env node
const fs = require("fs");
const os = require("os");
const path = require("path");
const yaml = require("js-yaml");
const { execSync } = require("child_process");
Expand Down Expand Up @@ -125,8 +126,8 @@ const writeModsConfiguration = () => {

// Map from camelCase to snake_case
const ServerConfigMap = {
runnersThreads: "runner_threads",
processorsCnt: "processors_cnt",
runnerCount: "runners_threads",
processorCount: "processors_cnt",
storageTimeout: "storage_timeout",
logConsole: "log_console",
logRotateKeep: "log_rotate_keep",
Expand All @@ -138,9 +139,12 @@ const start = async () => {
writeModsConfiguration();

const screeps = require("@screeps/launcher");
const cores = os.cpus().length;
const options = {
steam_api_key: process.env.STEAM_KEY || config.steamKey,
storage_disable: false,
processors_cnt: cores,
runners_cnt: Math.max(cores - 1, 1),
};

const serverOptions = config.serverOptions || {};
Expand All @@ -151,6 +155,10 @@ const start = async () => {
}
}

console.log(
"Starting server with options:",
JSON.stringify(options, null, 2),
);
await screeps.start(options, process.stdout);
};

Expand Down

0 comments on commit 1954702

Please sign in to comment.