From 20ddc5c89d07702fd2db110f5267bc588767b73a Mon Sep 17 00:00:00 2001 From: MrWhiff Date: Tue, 9 Dec 2025 21:11:48 +0100 Subject: [PATCH] AstraOS Ver. 1.8: - DC Bots werden nach restart automatisch gestartet --- AstraOS/astra_os.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/AstraOS/astra_os.py b/AstraOS/astra_os.py index 54a605f..2f1c36e 100644 --- a/AstraOS/astra_os.py +++ b/AstraOS/astra_os.py @@ -128,6 +128,12 @@ except Exception as e: accounts_collection = None logs_collection = None +# Autostart-Funktion für Bots im Produktions- und Entwicklungsmodus aufrufen +# Die Prüfung `os.environ.get('WERKZEUG_RUN_MAIN') != 'true'` verhindert, dass es im Debug-Modus doppelt ausgeführt wird. +if os.environ.get('WERKZEUG_RUN_MAIN') != 'true': + with app.app_context(): + start_bots_on_startup() + def start_bots_on_startup(): if discord_bots_collection is None: print("WARNUNG: Bot-Autostart übersprungen, da keine DB-Verbindung besteht.") @@ -969,6 +975,5 @@ def update_maintenance(): if __name__ == '__main__': app.config['SESSION_COOKIE_SECURE'] = False print("INFO: Starte den Server im Entwicklungsmodus ohne HTTPS.") - with app.app_context(): - start_bots_on_startup() + # Der Autostart wird hier nicht mehr benötigt, da er oben global aufgerufen wird. socketio.run(app, host='0.0.0.0', port=5000, debug=True, allow_unsafe_werkzeug=True)