From 02b54de9c4f391f75eb8287e3857ecda30d483a4 Mon Sep 17 00:00:00 2001 From: oppiliappan Date: Fri, 5 Sep 2025 14:28:54 +0100 Subject: [PATCH] appview/db: close once done Signed-off-by: oppiliappan --- appview/db/db.go | 4 ++++ appview/state/state.go | 5 +++++ cmd/appview/main.go | 3 +++ 3 files changed, 12 insertions(+) diff --git a/appview/db/db.go b/appview/db/db.go index ee37c9c2..99139418 100644 --- a/appview/db/db.go +++ b/appview/db/db.go @@ -749,6 +749,10 @@ func runMigration(c *sql.Conn, name string, migrationFn migrationFn) error { return nil } +func (d *DB) Close() error { + return d.DB.Close() +} + type filter struct { key string arg any diff --git a/appview/state/state.go b/appview/state/state.go index f3a8fa52..418d8d11 100644 --- a/appview/state/state.go +++ b/appview/state/state.go @@ -165,6 +165,11 @@ func Make(ctx context.Context, config *config.Config) (*State, error) { return state, nil } +func (s *State) Close() error { + // other close up logic goes here + return s.db.Close() +} + func (s *State) Favicon(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "image/svg+xml") w.Header().Set("Cache-Control", "public, max-age=31536000") // one year diff --git a/cmd/appview/main.go b/cmd/appview/main.go index f7435548..04e96382 100644 --- a/cmd/appview/main.go +++ b/cmd/appview/main.go @@ -23,6 +23,9 @@ func main() { } state, err := state.Make(ctx, c) + defer func() { + log.Println(state.Close()) + }() if err != nil { log.Fatal(err) -- 2.51.2