Scheduled-loop infra: lockfile guard + release + fire log
- scripts/loop-guard.sh — atomic claim with 30-min staleness overtake, appends NDJSON event to .loop-logs/<lang>.ndjson. Exit 0 = go ahead, exit 1 = another run is live, skip. - scripts/loop-release.sh — clear lock, log release with exit status. Intended for 7 per-language /schedule routines firing every 15 minutes. Lock detects overlap so tight cadences are safe; stale lock (>30 min) overtaken automatically if an agent dies mid-run.
This commit is contained in:
13
scripts/loop-release.sh
Executable file
13
scripts/loop-release.sh
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
LANG=${1:?usage: loop-release.sh <lang>}
|
||||
STATUS=${2:-done}
|
||||
ROOT=$(cd "$(dirname "$0")/.." && pwd)
|
||||
cd "$ROOT"
|
||||
LOCK=".loop-locks/$LANG.claim"
|
||||
LOG=".loop-logs/$LANG.ndjson"
|
||||
ISO=$(date -Iseconds)
|
||||
rm -f "$LOCK"
|
||||
printf '{"ts":"%s","lang":"%s","status":"released","exit":"%s"}\n' "$ISO" "$LANG" "$STATUS" >> "$LOG"
|
||||
echo "OK: $LANG released ($STATUS)"
|
||||
Reference in New Issue
Block a user