Skip to content

Commit

Permalink
chore: update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
ariscript committed Dec 27, 2021
1 parent 7c7cea0 commit 62a1b65
Show file tree
Hide file tree
Showing 2 changed files with 131 additions and 98 deletions.
12 changes: 9 additions & 3 deletions src/lib/instances/runInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ export async function runInstance(
const playerQuery = setInterval(async () => {
log.debug("Running periodic server query...");

if (!rconClient.isConnected) return; // don't query if the server isn't ready yet

try {
const results = await queryFull("localhost");

Expand All @@ -93,12 +95,12 @@ export async function runInstance(
oldPlayers = results.players.list;
}
} catch (e) {
log.silly(e);
log.debug(e);
}
}, 5000); // query results are cached for 5 seconds by the server

server.on("close", (code) => {
rconClient.close().catch((err) => log.error(err));
rconClient.close();

log.debug(
`SERVER ${info.name} closed with exit code ${code ?? "null"}`
Expand All @@ -118,7 +120,8 @@ export async function runInstance(
window.on("close", () => {
try {
server.stdin.write("stop\n"); // no need to wait for server to fully load this way
rconClient.close().catch((err) => log.error(err));
clearInterval(playerQuery);
rconClient.close();
} catch {
server.kill();
}
Expand All @@ -129,6 +132,9 @@ export async function runInstance(
return "To stop the server, please close the window. The stop command is not needed.";
}

if (!rconClient.isConnected)
return "RCON not connected. Try again after server loads.";

log.debug(`RCON command to ${info.name}: ${command}`);
const output = await rconClient.execute(command);
log.debug(`RCON output from ${info.name}: ${output}`);
Expand Down
Loading

0 comments on commit 62a1b65

Please # to comment.