Merge branch 'dev' into 'main'

Fix:MEP auto

See merge request Omega_Kube/kuby!34
This commit is contained in:
Gameur 2026-06-07 16:41:19 +02:00
commit ac4388998a
2 changed files with 17 additions and 6 deletions

View file

@ -236,7 +236,7 @@ class BugReport(commands.Cog):
app.router.add_post('/bot_event', self.handle_bot_event)
self.runner = web.AppRunner(app)
await self.runner.setup()
self.site = web.TCPSite(self.runner, '127.0.0.1', 5001)
self.site = web.TCPSite(self.runner, '127.0.0.1', 5001, reuse_address=True)
await self.site.start()
kuby_logger.info("Internal Bot Webhook Server started on 127.0.0.1:5001")
except Exception as e:

View file

@ -14,6 +14,9 @@ WEBHOOK_SECRET = "Nois2"
PROCESS_NAME = "kuby"
DISCORD_LOG_URL = "https://discord.com/api/webhooks/1482148910888652910/IA9CcOWtjGswbuxMaOu_6uaclv5zojZo4ttxtV6RYyZzJ9gW7BF7xp_Zv3oPIjYEuh8o"
# Chemin absolu vers le binaire PM2 (évite l'erreur 127 command not found)
PM2_BINARY = "/home/discord/.nvm/versions/node/v24.15.0/bin/pm2"
# Bot Local Proxy
BOT_LOCAL_URL = "http://127.0.0.1:5001/bot_event"
@ -63,7 +66,7 @@ def run_mep_logic(author, commit_msg, branch="main"):
if use_rsync:
subprocess.run(["rsync", "-a", "--exclude=.git", "--exclude=venv", "--exclude=.venv", "--exclude=__pycache__", f"{target_path}/", f"{PROJECT_PATH}/"], check=True)
# ⚡ NOUVEAU: Migration automatique GitLab tracking
# ⚡ Migration automatique GitLab tracking
send_discord_log("MIGRATION", "Migration GitLab tracking en cours...", 16776960, author, commit_msg)
try:
subprocess.run(
@ -77,17 +80,25 @@ def run_mep_logic(author, commit_msg, branch="main"):
except subprocess.CalledProcessError as e:
send_discord_log("ERREUR MIGRATION", f"❌ Migration GitLab échouée: {e.stderr}", 15158332, author, commit_msg)
# 3. PM2 (Appelé avant le message de succès)
# 3. PM2 (Appelé directement via son chemin absolu pour corriger l'erreur 127)
subprocess.run(
f"source /home/discord/.nvm/nvm.sh && pm2 restart {PROCESS_NAME}",
shell=True, check=True, capture_output=True, executable="/bin/bash"
[PM2_BINARY, "restart", PROCESS_NAME],
check=True,
capture_output=True,
text=True
)
duration = (datetime.now() - start_time).total_seconds()
msg = f"✅ **Déploiement réussi en {duration:.2f}s**\nLe bot est à jour et redémarré."
send_discord_log("VALIDÉ", msg, 3066993, author, commit_msg)
except subprocess.CalledProcessError as e:
# Capture spécifique si une commande système (comme Git ou PM2) crash
error_stderr = e.stderr if e.stderr else "Pas de log d'erreur disponible (stderr vide)."
error_msg = f"❌ **ERREUR de commande (Status {e.returncode})**\nCommande : `{ ' '.join(e.cmd) }`\n\n**Détails :**\n```\n{error_stderr}\n```"
send_discord_log("ÉCHEC", error_msg, 15158332, author, commit_msg)
except Exception as e:
# Capture globale pour le reste du script Python
error_msg = f"❌ **ERREUR de déploiement**\n```python\n{str(e)}\n```"
send_discord_log("ÉCHEC", error_msg, 15158332, author, commit_msg)
@ -140,4 +151,4 @@ def gitlab_webhook():
if __name__ == '__main__':
print(f"[*] Webhook opérationnel. En attente de push ou d'events...")
app.run(host='0.0.0.0', port=5000)
app.run(host='0.0.0.0', port=5000)