diff --git a/app/classes/models/servers.py b/app/classes/models/servers.py index 71ca4851..e22a428c 100644 --- a/app/classes/models/servers.py +++ b/app/classes/models/servers.py @@ -38,6 +38,7 @@ class Servers(BaseModel): logs_delete_after = IntegerField(default=0) type = CharField(default="minecraft-java") show_status = BooleanField(default=1) + shutdown_timeout = IntegerField(default=60) class Meta: table_name = "servers" diff --git a/app/classes/shared/server.py b/app/classes/shared/server.py index 499a0080..97192323 100644 --- a/app/classes/shared/server.py +++ b/app/classes/shared/server.py @@ -612,12 +612,15 @@ class ServerInstance: # caching the name and pid number server_name = self.name server_pid = self.process.pid + self.shutdown_timeout = self.settings["shutdown_timeout"] while running: i += 1 + ttk = int(self.shutdown_timeout - (i * 2)) logstr = ( f"Server {server_name} is still running " - f"- waiting 2s to see if it stops ({int(60-(i*2))} " + "- waiting 2s to see if it stops" + f"({ttk} " f"seconds until force close)" ) logger.info(logstr) @@ -626,7 +629,7 @@ class ServerInstance: time.sleep(2) # if we haven't closed in 60 seconds, let's just slam down on the PID - if i >= 30: + if i >= round(self.shutdown_timeout / 2, 0): logger.info( f"Server {server_name} is still running - Forcing the process down" ) diff --git a/app/classes/web/panel_handler.py b/app/classes/web/panel_handler.py index a5e56029..4f2ce71c 100644 --- a/app/classes/web/panel_handler.py +++ b/app/classes/web/panel_handler.py @@ -1418,6 +1418,7 @@ class PanelHandler(BaseHandler): return server_name = self.get_argument("server_name", None) server_obj = self.controller.servers.get_server_obj(server_id) + shutdown_timeout = self.get_argument("shutdown_timeout", 60) if superuser: server_path = self.get_argument("server_path", None) if Helpers.is_os_windows(): @@ -1498,6 +1499,7 @@ class PanelHandler(BaseHandler): ) server_obj.server_name = server_name + server_obj.shutdown_timeout = shutdown_timeout if superuser: if Helpers.validate_traversal( self.helper.get_servers_root_dir(), server_path diff --git a/app/frontend/templates/panel/server_config.html b/app/frontend/templates/panel/server_config.html index 6c9a8b36..cc3f7cf7 100644 --- a/app/frontend/templates/panel/server_config.html +++ b/app/frontend/templates/panel/server_config.html @@ -163,6 +163,17 @@ value="{{ data['server_stats']['server_id']['server_port'] }}" step="1" max="65566" min="1" required> +