fix: feat: stack lock protocol for singleton project stack access (#255)
All checks were successful
ci/woodpecker/push/ci Pipeline was successful

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Claude 2026-04-05 21:04:15 +00:00
parent a77aa19c3f
commit 564b8c90aa

View file

@ -98,6 +98,7 @@ stack_lock_acquire() {
lock_file="$(_stack_lock_path "$project")"
local deadline
deadline=$(( $(date -u +%s) + max_wait ))
local _rc=0
mkdir -p "$STACK_LOCK_DIR"
@ -130,17 +131,20 @@ stack_lock_acquire() {
remaining=$(( deadline - $(date -u +%s) ))
if [ "$remaining" -le 0 ]; then
echo "[stack-lock] timed out waiting for lock on ${project} (held by ${cur_holder})" >&2
return 1
_rc=1
break
fi
echo "[stack-lock] ${project} locked by ${cur_holder}, waiting ${STACK_LOCK_POLL_INTERVAL}s (${remaining}s left)..." >&2
sleep "$STACK_LOCK_POLL_INTERVAL"
;;
*)
echo "[stack-lock] unexpected status '${status}' for ${project}" >&2
return 1
_rc=1
break
;;
esac
done
return "$_rc"
}
# stack_lock_heartbeat <holder_id> <project>