-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
88 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
const stripAnsi = require("strip-ansi"); | ||
const Gamedig = require("gamedig"); | ||
const compose = require("docker-compose"); | ||
|
||
const { game, gameId, debugLog, connectUrl, rconPort } = require("../cliArgs"); | ||
const { dockerComposeStop, dockerComposePull } = require("./common-helpers"); | ||
const GenericDockerManager = require("./docker"); | ||
|
||
module.exports = class ValheimManager extends GenericDockerManager { | ||
getConnectUrl() { | ||
return `steam://connect/${connectUrl} (though use Steam Server browser)`; | ||
} | ||
stop() { | ||
// just docker-compose stop doesn't seem to shutdown cleanly (saving)... | ||
compose | ||
.exec(game, "bash -c 'cd /home/steam/valheim && ~steam/.odin/odin/stop") | ||
.then(() => { | ||
dockerComposeStop(); | ||
}); | ||
} | ||
async getPlayerCount() { | ||
try { | ||
const response = await Gamedig.query({ | ||
type: "css", // Gamedig lacks Valheim but css is compatible | ||
host: `localhost`, | ||
port: rconPort, | ||
socketTimeout: 3000, | ||
}); | ||
return response.players.length; | ||
} catch (err) { | ||
debugLog(`getPlayerCount err: ${err}`); | ||
return false; | ||
} | ||
} | ||
async update() { | ||
dockerComposePull() | ||
.then(res => { | ||
console.log("finished docker pull: ", res); | ||
this.setStatus("stopped"); | ||
}) | ||
.catch(e => { | ||
console.log("docker pull failed:", e); | ||
}); | ||
} | ||
async filesToBackup() { | ||
return ["saves"]; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
version: "3" | ||
services: | ||
valheim: | ||
container_name: valheim | ||
image: mbround18/valheim:latest | ||
environment: | ||
- PORT=2456 | ||
- NAME="Nebtown Yngheim" | ||
- PASSWORD="1234" | ||
- TZ=America/Vancouver | ||
- WORLD=Yngheim | ||
ports: | ||
- "2456:2456/udp" | ||
- "2457:2457/udp" | ||
- "2458:2458/udp" | ||
volumes: | ||
- ./saves:/home/steam/.config/unity3d/IronGate/Valheim | ||
- ./server:/home/steam/valheim |