From 362a079c69da427f38666a0e28d5196fa6a6da73 Mon Sep 17 00:00:00 2001 From: Charles Le Maux Date: Wed, 18 Sep 2024 11:04:35 +0200 Subject: [PATCH 1/2] [+] New API cleanup system --- app.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/app.py b/app.py index ad45b9c..f7aba6c 100644 --- a/app.py +++ b/app.py @@ -1,5 +1,4 @@ import argparse -import atexit import http import inspect import os @@ -9,6 +8,7 @@ from apscheduler.schedulers.background import BackgroundScheduler from firebase_admin.auth import UserNotFoundError, UserRecord from flask import (Blueprint, Flask, Response, jsonify, request) from flask_cors import CORS +from werkzeug import run_simple from werkzeug.datastructures import ImmutableMultiDict, FileStorage from werkzeug.utils import secure_filename @@ -17,7 +17,7 @@ import firebase_manager import generic_executor app = Flask(__name__) -app.config['MAX_CONTENT_LENGTH'] = 16 * 1000 * 1000 * 1000 #15.28MB~ +app.config['MAX_CONTENT_LENGTH'] = 16 * 1000 * 1000 * 1000 #15.28MB~ cors = CORS(app, origins="*") apiBP = Blueprint('apiBP', 'BPapi') @@ -179,22 +179,21 @@ def upload(): return generic_response_maker(http.HTTPStatus.OK, "Successfully uploaded files !") -def exit_safety() -> None: +def api_cleanup() -> None: firebase_manager.set_servers_not_running() return + app.register_blueprint(apiBP) if __name__ == '__main__': - parser = argparse.ArgumentParser(description="Background Scheduler") parser.add_argument('--interval', type=int, default=10, help="Interval in minutes") args = parser.parse_args() - atexit.register(exit_safety) - scheduler = BackgroundScheduler() scheduler.add_job(generic_executor.scheduled_actions, 'interval', minutes=args.interval) scheduler.start() - app.run(host='0.0.0.0', port=3000, debug=False) + run_simple('0.0.0.0', 3000, app, use_debugger=False, use_reloader=False) + api_cleanup() \ No newline at end of file From 2e6e13a67675bb60f7c6f279cd4812aa9c8860ab Mon Sep 17 00:00:00 2001 From: Charles Le Maux Date: Thu, 19 Sep 2024 12:24:56 +0200 Subject: [PATCH 2/2] [+] Updated modpack launch command Now the get_sdk_version won't be called on modded servers, preventing a non base 10 error (because the modpack's version name won't be represented as a minecraft version, but as the modpack name itself. --- server_mc_manager.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/server_mc_manager.py b/server_mc_manager.py index 6aab6e9..1a37012 100644 --- a/server_mc_manager.py +++ b/server_mc_manager.py @@ -36,10 +36,12 @@ class MinecraftServerManager: " -XX:MaxTenuringThreshold=1 -Daikars.new.flags=true" " -Dusing.aikars.flags=https://mcutils.com") - java: str = f"/usr/lib/jvm/java-{get_sdk_version(version)}-openjdk-amd64/bin/java" + command: str - command = f"{java} -Xmx{memory_size} {reg_flags} -jar {jar_file} --nogui" - if modded: + if not modded: + java: str = f"/usr/lib/jvm/java-{get_sdk_version(version)}-openjdk-amd64/bin/java" + command = f"{java} -Xmx{memory_size} {reg_flags} -jar {jar_file} --nogui" + else: command = "./start.sh" process = subprocess.Popen(shlex.split(command), cwd=server_directory, stdin=subprocess.PIPE)