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)