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> +
+ + +
{% end %}
diff --git a/app/migrations/20220821_shutdown_timeout.py b/app/migrations/20220821_shutdown_timeout.py new file mode 100644 index 00000000..68130360 --- /dev/null +++ b/app/migrations/20220821_shutdown_timeout.py @@ -0,0 +1,16 @@ +# Generated by database migrator +import peewee + + +def migrate(migrator, database, **kwargs): + migrator.add_columns("servers", shutdown_timeout=peewee.IntegerField(default=60)) + """ + Write your migrations here. + """ + + +def rollback(migrator, database, **kwargs): + migrator.drop_columns("servers", ["shutdown_timeout"]) + """ + Write your rollback migrations here. + """ diff --git a/app/translations/en_EN.json b/app/translations/en_EN.json index f398ccf5..4c73f2b0 100644 --- a/app/translations/en_EN.json +++ b/app/translations/en_EN.json @@ -324,7 +324,10 @@ "stopBeforeDeleting": "Please stop the server before deleting it", "update": "Update Executable", "yesDelete": "Yes, delete", - "yesDeleteFiles": "Yes, delete files" + "yesDeleteFiles": "Yes, delete files", + "shutdownTimeout": "Shutdown Timeout", + "timeoutExplain1": "How long Crafty will wait for your server to shutdown after executing the", + "timeoutExplain2": "command before it forces the process down." }, "serverConfigHelp": { "desc": "Here is where you can change the configuration of your server", @@ -558,4 +561,4 @@ "userSettings": "User Settings", "uses": "Number of uses allowed (-1==No Limit)" } -} +} \ No newline at end of file