Merge pull request 'feat: ajout des scripts pour le basculement automatique' (#284) from dev-truekiwwy into main

Reviewed-on: #284
This commit is contained in:
Gameur 2026-07-14 19:27:14 +00:00
commit 72d9959d03
2 changed files with 14 additions and 0 deletions

11
gerer_bot.sh Normal file
View file

@ -0,0 +1,11 @@
#!/bin/bash
ROLE=$(./verifier_role_db.sh)
BOT_TOURNE=$(docker ps -q -f name=bot-discord)
if [ "$ROLE" = "primary" ] && [ -z "$BOT_TOURNE" ]; then
docker start bot-discord
fi
if [ "$ROLE" = "replica" ] && [ -n "$BOT_TOURNE" ]; then
docker stop bot-discord
fi

3
verifier_role_db.sh Normal file
View file

@ -0,0 +1,3 @@
#!/bin/bash
ROLE=$(psql -U postgres -tAc "SELECT pg_is_in_recovery();")
[ "$ROLE" = "f" ] && echo "primary" || echo "replica"