From 694e0e45ed083c5f492f0a868ad5a3f2ffe7b1c6 Mon Sep 17 00:00:00 2001 From: hippoz <10706925-hippoz@users.noreply.gitlab.com> Date: Sat, 12 Mar 2022 17:08:52 +0200 Subject: [PATCH] fix server not closing on timeout --- scripts/minecraft.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/minecraft.js b/scripts/minecraft.js index 09ef5fc..e99f85d 100644 --- a/scripts/minecraft.js +++ b/scripts/minecraft.js @@ -11,7 +11,6 @@ import { spawn } from "node:child_process"; import Rcon from "rcon"; - const TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InN0YWdpbmctbWluZWNyYWZ0LWJyaWRnZSIsImF2YXRhclVSTCI6bnVsbCwiZGlzY29yZElEIjoiMCIsImd1aWxkQWNjZXNzIjpbIjczNjI5MjUwOTEzNDc0OTgwNyJdLCJpc1N1cGVyVG9rZW4iOnRydWUsImlhdCI6MTY0NDQ1MzM4MX0.-XIBl6VLnXVwve9iqhWs51ABZkm1i_v1tS6X01SPk3U"; // A supertoken is required to send messages from Minecraft. const TARGET_GUILD_ID = "_"; const TARGET_CHANNEL_ID = "_"; @@ -370,6 +369,9 @@ class Bridge { setTimeout(() => { if (this.playerCount === 0) { console.log("server job: no players on server after 5 minutes, closing..."); + if (this.process) { + this.process.kill("SIGINT"); + } this.sendBridgeMessageAs(TARGET_GUILD_ID, TARGET_CHANNEL_ID, ":pensive: Server was started, yet no one joined after 5 minutes. Closing again...", null, null); } }, 300000);