Files
Substack_JV/update_and_run.sh
2025-09-08 18:31:28 +02:00

30 lines
860 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/sh
set -eu
# 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
# (facultatif si tu fais un git pull ici)
# git fetch --all || true
# git reset --hard origin/main || true
# Lancer les 2 bots en arrière-plan
python -u post_rss_to_ghost.py & PID1=$!
python -u presquegratos.py & PID2=$!
# Attendre qu'un des deux termine; l'autre sera tué dans stop()
# /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