Fix:MEP auto
This commit is contained in:
parent
f1c0921a58
commit
69cc25b99a
2 changed files with 17 additions and 6 deletions
|
|
@ -236,7 +236,7 @@ class BugReport(commands.Cog):
|
||||||
app.router.add_post('/bot_event', self.handle_bot_event)
|
app.router.add_post('/bot_event', self.handle_bot_event)
|
||||||
self.runner = web.AppRunner(app)
|
self.runner = web.AppRunner(app)
|
||||||
await self.runner.setup()
|
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()
|
await self.site.start()
|
||||||
kuby_logger.info("Internal Bot Webhook Server started on 127.0.0.1:5001")
|
kuby_logger.info("Internal Bot Webhook Server started on 127.0.0.1:5001")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,9 @@ WEBHOOK_SECRET = "Nois2"
|
||||||
PROCESS_NAME = "kuby"
|
PROCESS_NAME = "kuby"
|
||||||
DISCORD_LOG_URL = "https://discord.com/api/webhooks/1482148910888652910/IA9CcOWtjGswbuxMaOu_6uaclv5zojZo4ttxtV6RYyZzJ9gW7BF7xp_Zv3oPIjYEuh8o"
|
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 Proxy
|
||||||
BOT_LOCAL_URL = "http://127.0.0.1:5001/bot_event"
|
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:
|
if use_rsync:
|
||||||
subprocess.run(["rsync", "-a", "--exclude=.git", "--exclude=venv", "--exclude=.venv", "--exclude=__pycache__", f"{target_path}/", f"{PROJECT_PATH}/"], check=True)
|
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)
|
send_discord_log("MIGRATION", "Migration GitLab tracking en cours...", 16776960, author, commit_msg)
|
||||||
try:
|
try:
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
|
|
@ -77,17 +80,25 @@ def run_mep_logic(author, commit_msg, branch="main"):
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
send_discord_log("ERREUR MIGRATION", f"❌ Migration GitLab échouée: {e.stderr}", 15158332, author, commit_msg)
|
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(
|
subprocess.run(
|
||||||
f"source /home/discord/.nvm/nvm.sh && pm2 restart {PROCESS_NAME}",
|
[PM2_BINARY, "restart", PROCESS_NAME],
|
||||||
shell=True, check=True, capture_output=True, executable="/bin/bash"
|
check=True,
|
||||||
|
capture_output=True,
|
||||||
|
text=True
|
||||||
)
|
)
|
||||||
|
|
||||||
duration = (datetime.now() - start_time).total_seconds()
|
duration = (datetime.now() - start_time).total_seconds()
|
||||||
msg = f"✅ **Déploiement réussi en {duration:.2f}s**\nLe bot est à jour et redémarré."
|
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)
|
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:
|
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```"
|
error_msg = f"❌ **ERREUR de déploiement**\n```python\n{str(e)}\n```"
|
||||||
send_discord_log("ÉCHEC", error_msg, 15158332, author, commit_msg)
|
send_discord_log("ÉCHEC", error_msg, 15158332, author, commit_msg)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue