Merge branch 'dev' into 'main'
V1.2 du système de gestions des rapports d'utilisateur #2 See merge request Omega_Kube/kuby!6
This commit is contained in:
commit
53869aa670
2 changed files with 30 additions and 0 deletions
29
bot.py
29
bot.py
|
|
@ -12,6 +12,8 @@ import asyncio
|
|||
from src.logger import kuby_logger, log_performance
|
||||
import logging
|
||||
from src.advanced_logger import AdvancedLogger
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
# Récupération et validation de l'ID d'application
|
||||
application_id_raw = os.getenv("APPLICATION_ID")
|
||||
|
|
@ -47,6 +49,23 @@ class MyBot(commands.Bot):
|
|||
self.advanced_logger = AdvancedLogger(self)
|
||||
kuby_logger.info("✅ Advanced logger initialized")
|
||||
|
||||
# Start the Flask Webhook Server
|
||||
self.flask_process = None
|
||||
try:
|
||||
flask_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "serveur_flask.py")
|
||||
if os.path.exists(flask_path):
|
||||
self.flask_process = subprocess.Popen(
|
||||
[sys.executable, flask_path],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
cwd=os.path.dirname(flask_path)
|
||||
)
|
||||
kuby_logger.info(f"✅ Serveur Flask démarré (PID: {self.flask_process.pid})")
|
||||
else:
|
||||
kuby_logger.warning(f"⚠️ Fichier serveur_flask.py introuvable à {flask_path}")
|
||||
except Exception as e:
|
||||
kuby_logger.error(f"❌ Impossible de démarrer le serveur Flask: {e}")
|
||||
|
||||
# Charger les extensions
|
||||
extensions = [
|
||||
"commandes.whitelist",
|
||||
|
|
@ -130,6 +149,16 @@ class MyBot(commands.Bot):
|
|||
except Exception as e:
|
||||
kuby_logger.error(f"❌ Erreur lors de la synchronisation des commandes slash : {e}", exc_info=True)
|
||||
|
||||
async def close(self):
|
||||
if hasattr(self, 'flask_process') and self.flask_process:
|
||||
kuby_logger.info("Arrêt du serveur Flask interne...")
|
||||
self.flask_process.terminate()
|
||||
try:
|
||||
self.flask_process.wait(timeout=5)
|
||||
except subprocess.TimeoutExpired:
|
||||
self.flask_process.kill()
|
||||
await super().close()
|
||||
|
||||
# --- ÉVÉNEMENTS RESTAURÉS ---
|
||||
|
||||
async def on_ready(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue