fix(dashboard): harden generation against common failures
This commit is contained in:
@@ -1,10 +1,23 @@
|
||||
#!/bin/sh
|
||||
# Keep docs/campaign_dashboard.svg fresh: regenerate every 60 s.
|
||||
# Errors go to stderr and never exit the loop silently.
|
||||
dir=$(dirname "$0")
|
||||
# Failures are appended to tools/plot_progress.log (by this wrapper and by
|
||||
# plot_progress.py itself) - check that file when the dashboard looks stale.
|
||||
# The startup banner records WHICH tree this instance watches, so a copy
|
||||
# launched from a stale checkout (the post-reboot failure mode) is visible.
|
||||
set -u
|
||||
dir=$(cd "$(dirname "$0")" && pwd)
|
||||
log="$dir/plot_progress.log"
|
||||
|
||||
if command -v flock >/dev/null 2>&1; then
|
||||
exec 9>"$dir/.watch_dashboard.lock"
|
||||
flock -n 9 || { echo "[watch_dashboard] another instance already running, exiting" >&2; exit 0; }
|
||||
fi
|
||||
|
||||
echo "[watch_dashboard] $(date '+%F %T') started, watching root=$(cd "$dir/.." && pwd)" >> "$log" 2>/dev/null || true
|
||||
while :; do
|
||||
if ! python3 "$dir/plot_progress.py"; then
|
||||
echo "[watch_dashboard] $(date '+%F %T') regeneration failed (see error above)" >&2
|
||||
echo "[watch_dashboard] $(date '+%F %T') regeneration failed (see $log)" >&2
|
||||
echo "[watch_dashboard] $(date '+%F %T') regeneration failed" >> "$log" 2>/dev/null || true
|
||||
fi
|
||||
sleep 60
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user