Files
mopac-pmo/scripts/queue-next.sh
T
mrcharles 79d93b6c49 ops(scripts): dispatch, queue gating, heartbeat, quota probe
dispatch-turn.sh (headless turn launcher with TURN_MODEL routing),
queue-after.sh (serial gate chain + quota-wall guard), pmo-heartbeat.sh
(PMO wake loop), quota-probe-then-chain.sh (post-wall relaunch).
2026-08-29 05:22:43 -05:00

28 lines
999 B
Bash
Executable File

#!/usr/bin/env bash
# queue-next.sh — bash-only slot watcher: run queued TASK turns as slots free.
# rc=3 from dispatch = DEFERRED (cap) -> keep waiting on same task, don't exit.
set -uo pipefail
LOGDIR="$HOME/.coordinate/logs"
i=1
while [ $i -le $# ]; do
task=${!i}
i=$((i+1))
slug=$(basename "$task" .md | sed 's/^TASK-[0-9]*-[0-9]*-//')
while true; do
n=$(ls /home/_crossfeed/metrics/active/*.pid 2>/dev/null | wc -l)
[ "$n" -lt 2 ] && break
sleep 60
done
echo "$(date -Is) RUN $slug" >> "$LOGDIR/queue.status"
bash "$HOME/.coordinate/scripts/dispatch-turn.sh" "q-$slug" "$task" \
>> "$LOGDIR/queue-$slug.log" 2>&1
rc=$?
if [ "$rc" = 3 ]; then
echo "$(date -Is) DEFER $slug (cap) - re-queueing" >> "$LOGDIR/queue.status"
i=$((i-1)); sleep 30; continue
fi
echo "$(date -Is) $([ $rc -eq 0 ] && echo OK || echo FAIL) $slug rc=$rc" >> "$LOGDIR/queue.status"
[ $rc -ne 0 ] && exit $rc
done
echo "$(date -Is) queue complete" >> "$LOGDIR/queue.status"