feat: add in-memory queue to serialize the redeploy webhook - #52
Open
Zareix wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
POST /api/stacks/redeploycallsredeployAllRunningStacks()directly and awaits it. When a registry fires several webhooks in a burst (one per pushed image), each request starts its own full pass — twodocker compose upruns can hit the same stacks concurrently, and N redundant passes run for a single burst.Change
Adds a generic in-memory task queue built on p-queue (
src/lib/queue.ts), plus a thin redeploy consumer (src/lib/redeploy-queue.ts) that:The route now returns
202 Acceptedimmediately with the queue status instead of blocking until all stacks finish, andGET /api/stacks/redeployexposes the current{ running, queued }state.createTaskQueueis generic and reusable for any async task (prune, image pulls, …).Alternative (SQLite-persistent)
See #53 for the same feature backed by bunqueue (persistent, retries, DLQ).
Notes / trade-offs
tsc --noEmitis clean for these changes; the client + SSR bundles build fine. The final Nitro externals-tracing step fails on a pre-existing, unrelated issue (missing optional native depcpu-featuresunderdockerode→docker-modem→ssh2).bun run checkbefore merging.