Skip to content

Commit

Permalink
Various bug fixes, stability improvements and overall cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Dids committed Jan 1, 2019
1 parent bf93312 commit bed49fd
Show file tree
Hide file tree
Showing 15 changed files with 652 additions and 317 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ ENV RUST_UPDATE_BRANCH "public"
ENV RUST_START_MODE "0"
ENV RUST_OXIDE_ENABLED "0"
ENV RUST_OXIDE_UPDATE_ON_BOOT "1"
ENV RUST_SERVER_WORLDSIZE "3500"
ENV RUST_SERVER_WORLDSIZE "4000"
ENV RUST_SERVER_MAXPLAYERS "500"
ENV RUST_SERVER_SAVE_INTERVAL "600"

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ The following environment variables are available:
RUST_SERVER_STARTUP_ARGUMENTS (DEFAULT: "-batchmode -load +server.secure 1")
RUST_SERVER_IDENTITY (DEFAULT: "docker" - Mainly used for the name of the save directory)
RUST_SERVER_SEED (DEFAULT: "12345" - The server map seed, must be an integer)
RUST_SERVER_WORLDSIZE (DEFAULT: "3500" - The map size, must be an integer)
RUST_SERVER_WORLDSIZE (DEFAULT: "4000" - The map size, must be an integer)
RUST_SERVER_NAME (DEFAULT: "Rust Server [DOCKER]" - The publicly visible server name)
RUST_SERVER_MAXPLAYERS (DEFAULT: "500" - Maximum players on the server, must be an integer)
RUST_SERVER_DESCRIPTION (DEFAULT: "This is a Rust server running inside a Docker container!" - The publicly visible server description)
Expand Down
7 changes: 5 additions & 2 deletions docker_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

./docker_build.sh

# Run a server without a volume mount (also doesn't remove it after termination)
# docker run -p 0.0.0.0:28015:28015 -p 0.0.0.0:28015:28015/udp -p 0.0.0.0:28016:28016 -p 0.0.0.0:8080:8080 -m 4g --name rust-server -it didstopia/rust-server:latest

# Run a vanilla server
docker run -p 0.0.0.0:28015:28015 -p 0.0.0.0:28015:28015/udp -p 0.0.0.0:28016:28016 -p 0.0.0.0:8080:8080 -m 2g -v $(pwd)/rust_data:/steamcmd/rust --name rust-server -it --rm didstopia/rust-server:latest
docker run -p 0.0.0.0:28015:28015 -p 0.0.0.0:28015:28015/udp -p 0.0.0.0:28016:28016 -p 0.0.0.0:8080:8080 -m 4g -v $(pwd)/rust_data:/steamcmd/rust --name rust-server -it --rm didstopia/rust-server:latest

# Run a modded server
#docker run -p 0.0.0.0:28015:28015 -p 0.0.0.0:28015:28015/udp -p 0.0.0.0:28016:28016 -p 0.0.0.0:8080:8080 -e RUST_OXIDE_ENABLED=1 -m 2g -v $(pwd)/rust_data:/steamcmd/rust --name rust-server -it --rm didstopia/rust-server:latest
#docker run -p 0.0.0.0:28015:28015 -p 0.0.0.0:28015:28015/udp -p 0.0.0.0:28016:28016 -p 0.0.0.0:8080:8080 -e RUST_OXIDE_ENABLED=1 -m 4g -v $(pwd)/rust_data:/steamcmd/rust --name rust-server -it --rm didstopia/rust-server:latest
121 changes: 53 additions & 68 deletions rcon_app/app.js
Original file line number Diff line number Diff line change
@@ -1,78 +1,63 @@
#!/usr/bin/env node

var argumentString = "";
var args = process.argv.splice(process.execArgv.length + 2);
for (var i = 0; i < args.length; i++)
{
if (i == args.length - 1) argumentString += args[i];
else argumentString += args[i] + " "
var argumentString = ''
var args = process.argv.splice(process.execArgv.length + 2)
for (var i = 0; i < args.length; i++) {
if (i === args.length - 1) argumentString += args[i]
else argumentString += args[i] + ' '
}

if (argumentString.length < 1)
{
console.log("Error: Please specify an RCON command");
process.exit();
if (argumentString.length < 1) {
console.log('Error: Please specify an RCON command')
process.exit()
}

//console.log("Relaying RCON command: " + argumentString);
// console.log("Relaying RCON command: " + argumentString);

var serverHostname = 'localhost';
var serverPort = process.env.RUST_RCON_PORT;
var serverPassword = process.env.RUST_RCON_PASSWORD;
var serverHostname = 'localhost'
var serverPort = process.env.RUST_RCON_PORT
var serverPassword = process.env.RUST_RCON_PASSWORD

var messageSent = false;
var WebSocket = require('ws');
var ws = new WebSocket("ws://" + serverHostname + ":" + serverPort + "/" + serverPassword);
ws.on('open', function open()
{
setTimeout(function()
{
messageSent = true;
ws.send(createPacket(argumentString));
setTimeout(function()
{
ws.close(1000);
setTimeout(function()
{
//console.log("Command relayed");
process.exit();
});
}, 1000);
}, 250);
});
ws.on('message', function(data, flags)
{
if (!messageSent) return;
try
{
var json = JSON.parse(data);
if (json !== undefined)
{
if (json.Message !== undefined && json.Message.length > 0)
{
console.log(json.Message);
}
}
else console.log("Error: Invalid JSON received");
}
catch(e)
{
if (e) console.log(e);
}
});
ws.on('error', function(e)
{
console.log(e);
process.exit();
});
var messageSent = false
var WebSocket = require('ws')
var ws = new WebSocket('ws://' + serverHostname + ':' + serverPort + '/' + serverPassword)
ws.on('open', function open () {
setTimeout(function () {
messageSent = true
ws.send(createPacket(argumentString))
setTimeout(function () {
ws.close(1000)
setTimeout(function () {
// console.log("Command relayed");
process.exit()
})
}, 1000)
}, 250)
})
ws.on('message', function (data, flags) {
if (!messageSent) return
try {
var json = JSON.parse(data)
if (json !== undefined) {
if (json.Message !== undefined && json.Message.length > 0) {
console.log(json.Message)
}
} else console.log('Error: Invalid JSON received')
} catch (e) {
if (e) console.log(e)
}
})
ws.on('error', function (e) {
console.log(e)
process.exit()
})

function createPacket(command)
{
var packet =
{
Identifier: -1,
Message: command,
Name: "WebRcon"
};
return JSON.stringify(packet);
function createPacket (command) {
var packet =
{
Identifier: -1,
Message: command,
Name: 'WebRcon'
}
return JSON.stringify(packet)
}
21 changes: 21 additions & 0 deletions rcon_app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rcon_app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"author": "",
"private": "true",
"dependencies": {
"ws": "^4.0.0"
"ws": "^6.1.2"
}
}
Loading

0 comments on commit bed49fd

Please sign in to comment.