AstraOS Ver. 1.13.2:

- Scrolling Fix hhotfix
- Bot startup fehler gefixt
This commit is contained in:
MrWhiff 2025-12-12 18:09:29 +01:00
parent 06f2e9ff10
commit fcc0dd8d4a
2 changed files with 66 additions and 4 deletions

View file

@ -311,4 +311,40 @@
{% with messages = get_flashed_messages(with_categories=true) %} {% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %} {% if messages %}
<div class="toast-container" x-data> <div class="toast-container" x-data>
{% for category, message in messages %}
<div x-data="{ show: true }" x-init="setTimeout(() => show = false, 5000)" x-show="show"
x-transition:enter="toast transition ease-out duration-300"
x-transition:enter-start="opacity-0 translate-x-8"
x-transition:enter-end="opacity-100 translate-x-0"
x-transition:leave="toast transition ease-in duration-300"
x-transition:leave-start="opacity-100"
x-transition:leave-end="opacity-0"
class="toast bg-gray-800 shadow-lg rounded-lg pointer-events-auto ring-1 ring-black ring-opacity-5 overflow-hidden p-4 border border-{{ 'red' if category == 'danger' else ('green' if category == 'success' else ('blue' if category == 'info' else 'gray')) }}-500/40">
<div class="flex items-start gap-3">
<div class="flex-shrink-0">
{% if category == 'success' %}
<svg class="h-6 w-6 text-green-400" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" /></svg>
{% elif category == 'danger' %}
<svg class="h-6 w-6 text-red-400" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" /></svg>
{% else %}
<svg class="h-6 w-6 text-blue-400" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" /></svg>
{% endif %}
</div>
<div class="flex-1">
<p class="text-sm font-medium text-gray-100">{{ message }}</p>
</div>
</div>
</div>
{% endfor %}
</div>
{% endif %}
{% endwith %}
<main class="flex-1 p-8 space-y-10 overflow-y-auto max-h-screen" id="mainContent">
{% block content %}{% endblock %}
</main>
<footer>
&copy; 2025 AstraOS
</footer>
</div>
</div>
<!-- ...existing code... -->

View file

@ -178,8 +178,35 @@ def start_bots_on_startup():
except Exception as e: except Exception as e:
print(f"FEHLER: Bot '{bot_info['name']}' konnte nicht gestartet werden: {e}") print(f"FEHLER: Bot '{bot_info['name']}' konnte nicht gestartet werden: {e}")
# Autostart-Funktion für Bots im Produktions- und Entwicklungsmodus aufrufen def stream_bot_output(bot_id, process):
# Die Prüfung `os.environ.get('WERKZEUG_RUN_MAIN') != 'true'` verhindert, dass es im Debug-Modus doppelt ausgeführt wird. 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': if os.environ.get('WERKZEUG_RUN_MAIN') != 'true':
with app.app_context(): with app.app_context():
start_bots_on_startup() start_bots_on_startup()
@ -1161,5 +1188,4 @@ def update_maintenance():
if __name__ == '__main__': if __name__ == '__main__':
app.config['SESSION_COOKIE_SECURE'] = False app.config['SESSION_COOKIE_SECURE'] = False
print("INFO: Starte den Server im Entwicklungsmodus ohne HTTPS.") 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) socketio.run(app, host='0.0.0.0', port=5000, debug=True, allow_unsafe_werkzeug=True)