diff --git a/AstraOS/Frontend/HTML/sidebar.html b/AstraOS/Frontend/HTML/sidebar.html
index 8aa077c..53d6cef 100644
--- a/AstraOS/Frontend/HTML/sidebar.html
+++ b/AstraOS/Frontend/HTML/sidebar.html
@@ -311,4 +311,40 @@
{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}
-
+ {% for category, message in messages %}
+
+
+
+ {% if category == 'success' %}
+
+ {% elif category == 'danger' %}
+
+ {% else %}
+
+ {% endif %}
+
+
+
+
+ {% endfor %}
+
+ {% endif %}
+ {% endwith %}
+
+ {% block content %}{% endblock %}
+
+
+
+
+
diff --git a/AstraOS/astra_os.py b/AstraOS/astra_os.py
index db6acf9..b3d97b7 100644
--- a/AstraOS/astra_os.py
+++ b/AstraOS/astra_os.py
@@ -178,8 +178,35 @@ def start_bots_on_startup():
except Exception as e:
print(f"FEHLER: Bot '{bot_info['name']}' konnte nicht gestartet werden: {e}")
-# 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.
+def stream_bot_output(bot_id, process):
+ def stream_to_socket(pipe, log_type):
+ try:
+ for line in iter(pipe.readline, ''):
+ log_entry = {'type': log_type, 'data': line}
+ if bot_id in running_bots:
+ running_bots[bot_id]['history'].append(log_entry)
+ max_history_lines = 1000
+ if len(running_bots[bot_id]['history']) > max_history_lines:
+ running_bots[bot_id]['history'].pop(0)
+ socketio.emit('console_output', log_entry, room=bot_id)
+ except Exception as e:
+ print(f"Stream-Fehler für Bot {bot_id}: {e}")
+ finally:
+ if pipe:
+ pipe.close()
+ stdout_thread = threading.Thread(target=stream_to_socket, args=(process.stdout, 'stdout'))
+ stderr_thread = threading.Thread(target=stream_to_socket, args=(process.stderr, 'stderr'))
+ stdout_thread.start()
+ stderr_thread.start()
+ process.wait()
+ if bot_id in running_bots:
+ del running_bots[bot_id]
+ if discord_bots_collection:
+ discord_bots_collection.update_one({'_id': ObjectId(bot_id)}, {'$set': {'status': 'stopped'}})
+ socketio.emit('status_update', {'bot_id': bot_id, 'status': 'stopped'}, room=bot_id)
+ socketio.emit('console_output', {'bot_id': bot_id, 'type': 'system', 'data': '--- Bot-Prozess beendet ---'}, room=bot_id)
+
+# Nach Definition von stream_bot_output: Autostart aufrufen (nur einmal; verhindert Doppelexekution beim Werkzeug-Reloader)
if os.environ.get('WERKZEUG_RUN_MAIN') != 'true':
with app.app_context():
start_bots_on_startup()
@@ -1161,5 +1188,4 @@ def update_maintenance():
if __name__ == '__main__':
app.config['SESSION_COOKIE_SECURE'] = False
print("INFO: Starte den Server im Entwicklungsmodus ohne HTTPS.")
- # 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)