diff --git a/app/classes/models/servers.py b/app/classes/models/servers.py index 69d05866..96f606a9 100644 --- a/app/classes/models/servers.py +++ b/app/classes/models/servers.py @@ -40,6 +40,7 @@ class Servers(BaseModel): show_status = BooleanField(default=1) created_by = IntegerField(default=-100) shutdown_timeout = IntegerField(default=60) + ignored_exits = CharField(default="0") class Meta: table_name = "servers" diff --git a/app/classes/shared/server.py b/app/classes/shared/server.py index 1b277a76..e1908dc3 100644 --- a/app/classes/shared/server.py +++ b/app/classes/shared/server.py @@ -730,26 +730,26 @@ class ServerInstance: self.server_thread.join() def stop_server(self): - if self.settings["stop_command"]: - self.send_command(self.settings["stop_command"]) - if self.settings["crash_detection"]: - # remove crash detection watcher - logger.info(f"Removing crash watcher for server {self.name}") - try: - self.server_scheduler.remove_job("c_" + str(self.server_id)) - except: - logger.error( - f"Removing crash watcher for server {self.name} failed. " - f"Assuming it was never started." - ) - else: - # windows will need to be handled separately for Ctrl+C - self.process.terminate() running = self.check_running() if not running: logger.info(f"Can't stop server {self.name} if it's not running") Console.info(f"Can't stop server {self.name} if it's not running") return + if self.settings["crash_detection"]: + # remove crash detection watcher + logger.info(f"Removing crash watcher for server {self.name}") + try: + self.server_scheduler.remove_job("c_" + str(self.server_id)) + except: + logger.error( + f"Removing crash watcher for server {self.name} failed. " + f"Assuming it was never started." + ) + if self.settings["stop_command"]: + self.send_command(self.settings["stop_command"]) + else: + # windows will need to be handled separately for Ctrl+C + self.process.terminate() i = 0 # caching the name and pid number @@ -919,7 +919,7 @@ class ServerInstance: if running: return # check the exit code -- This could be a fix for /stop - if self.process.returncode == 0: + if str(self.process.returncode) in self.settings["ignored_exits"].split(","): logger.warning( f"Process {self.process.pid} exited with code " f"{self.process.returncode}. This is considered a clean exit" diff --git a/app/classes/web/panel_handler.py b/app/classes/web/panel_handler.py index 74c93b88..5e78f628 100644 --- a/app/classes/web/panel_handler.py +++ b/app/classes/web/panel_handler.py @@ -1585,6 +1585,8 @@ class PanelHandler(BaseHandler): crash_detection = int(float(self.get_argument("crash_detection", "0"))) logs_delete_after = int(float(self.get_argument("logs_delete_after", "0"))) java_selection = self.get_argument("java_selection", None) + # make sure there is no whitespace + ignored_exits = " ".join(self.get_argument("ignored_exits", "").split()) # subpage = self.get_argument('subpage', None) server_id = self.check_server_id() @@ -1669,6 +1671,7 @@ class PanelHandler(BaseHandler): server_obj.auto_start = auto_start server_obj.crash_detection = crash_detection server_obj.logs_delete_after = logs_delete_after + server_obj.ignored_exits = ignored_exits failed = False for servers in self.controller.servers.failed_servers: if servers["server_id"] == int(server_id): diff --git a/app/frontend/templates/panel/server_config.html b/app/frontend/templates/panel/server_config.html index fb19ec05..2598a41d 100644 --- a/app/frontend/templates/panel/server_config.html +++ b/app/frontend/templates/panel/server_config.html @@ -184,6 +184,17 @@ value="{{ data['server_stats']['server_id']['shutdown_timeout'] }}" step="2" max="300" min="60" required> +