Fix:MEP auto
This commit is contained in:
parent
f1c0921a58
commit
69cc25b99a
2 changed files with 17 additions and 6 deletions
|
|
@ -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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue