Fix/app lifecycle shutdown drain - #170
Open
Qsnh wants to merge 2 commits into
Open
Conversation
WeComConfig was missing its closing brace, so TelegramConfig was parsed as part of its field list and internal/infra/config failed to compile: config.go:185:1: syntax error: unexpected keyword type, expected field name or embedded type This broke `go build ./...` on main. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
App.Run cancelled the runner context and then closed the database without
waiting for any of the eight fire-and-forget goroutines. The feeder,
scheduler, dispatcher, reconciler and token-stats syncer all touch the
database on their way out of a cancelled loop, so shutdown raced against
db.Close.
Rebuild Run around errgroup, already the concurrency idiom used elsewhere
in this repo. `defer a.db.Close()` is declared before g.Wait(), so it
unwinds only after every runner has returned. A server error now cancels
the group and propagates out of Run, so `openbee server` exits non-zero
instead of logging and returning success.
Also folded in, all in the same shutdown path:
- Build the platform sender map in one shot (buildSenders) instead of
handing an empty map to the failure notifier and filling it afterwards.
- Move startup recovery out of BuildApp into App.run, so constructing an
App no longer mutates the database.
- Extract the hidden os.Setenv("OPENBEE_URL") out of buildAllEngines into
publishRPCBaseURL.
- Guard routes.Server.httpServer with a mutex; Run wrote it while
Shutdown read it from another goroutine.
- Name each runner so exits are traceable in logs.
Tests drive App.run directly through an httpServer stub. Verified to fail
against the previous behaviour before being committed.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
No description provided.