This commit is contained in:
Gaël
2025-09-08 18:31:28 +02:00
parent fae2482067
commit 7b1ee4a0ab

View File

@@ -1,14 +1,29 @@
#!/bin/bash #!/bin/sh
set -euo pipefail set -eu
trap 'echo "[stop] shutting down..."; kill 0' SIGINT SIGTERM # Arrêt propre: en sh, on utilise INT/TERM (sans "SIG")
stop() {
echo "[stop] shutting down..."
# Tuer proprement les 2 enfants si présents
[ -n "${PID1-}" ] && kill -TERM "$PID1" 2>/dev/null || true
[ -n "${PID2-}" ] && kill -TERM "$PID2" 2>/dev/null || true
wait || true
exit 0
}
trap stop INT TERM
git fetch --all || true # (facultatif si tu fais un git pull ici)
git reset --hard origin/main || true # git fetch --all || true
# git reset --hard origin/main || true
# Lancer les 2 bots en parallèle # Lancer les 2 bots en arrière-plan
python -u post_rss_to_ghost.py & PID1=$! python -u post_rss_to_ghost.py & PID1=$!
python -u presquegratos.py & PID2=$! python -u presquegratos.py & PID2=$!
# Attendre que l'un des deux meure (et laisser l'autre se faire tuer par le trap) # Attendre qu'un des deux termine; l'autre sera tué dans stop()
wait -n "$PID1" "$PID2" || true # /bin/sh na pas toujours wait -n, on fait un petit poll
while :; do
if ! kill -0 "$PID1" 2>/dev/null; then wait "$PID1" || true; break; fi
if ! kill -0 "$PID2" 2>/dev/null; then wait "$PID2" || true; break; fi
sleep 1
done