diff --git a/app/__init__.py b/app/__init__.py index e64bfb4..7f103d8 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -1,13 +1,19 @@ # app/__init__.py +import logging +import threading +import time +import pygame + from flask import Flask -from .utils.logging import setup_logging + +from .utils.logging import setup_logging, cleanup_old_log_dirs from .routes.main import main_bp from .routes.admin import admin_bp from .routes.api import api_bp -import threading -import pygame +from .bluetooth.manager import init_bluetooth +logger = logging.getLogger(__name__) # ← Logger für diese Datei def create_app(): app = Flask(__name__) @@ -16,21 +22,9 @@ def create_app(): app.config.from_object('config.Config') # Logging zuerst (vor allem anderen) - from .utils.logging import setup_logging, cleanup_old_log_dirs setup_logging(app) - # Täglicher Cleanup-Thread starten (einmalig) - def daily_cleanup(): - while True: - cleanup_old_log_dirs(90) - time.sleep(86400) # 24 Stunden - - cleanup_thread = threading.Thread(target=daily_cleanup, daemon=True) - cleanup_thread.start() - logger.info("Täglicher Log-Cleanup-Thread gestartet (24h Intervall)") - # Bluetooth initialisieren (Monitor-Thread startet automatisch) - from .bluetooth.manager import init_bluetooth init_bluetooth() # pygame initialisieren (einmalig) @@ -48,4 +42,14 @@ def create_app(): app.register_blueprint(admin_bp, url_prefix='/admin') app.register_blueprint(api_bp, url_prefix='/api') + # Täglicher Cleanup-Thread starten (einmalig) + def daily_cleanup(): + while True: + cleanup_old_log_dirs(90) + time.sleep(86400) # 24 Stunden + + cleanup_thread = threading.Thread(target=daily_cleanup, daemon=True) + cleanup_thread.start() + logger.info("Täglicher Log-Cleanup-Thread gestartet (24h Intervall)") + return app \ No newline at end of file