diff --git a/api.go b/api.go index 18ac72fe..f5de5038 100644 --- a/api.go +++ b/api.go @@ -52,7 +52,7 @@ func (h *Headscale) HealthHandler( } } - if err := h.pingDB(); err != nil { + if err := h.pingDB(req.Context()); err != nil { respond(err) return diff --git a/db.go b/db.go index 17df384d..a1a4ef33 100644 --- a/db.go +++ b/db.go @@ -221,8 +221,8 @@ func (h *Headscale) setValue(key string, value string) error { return nil } -func (h *Headscale) pingDB() error { - ctx, cancel := context.WithTimeout(context.Background(), time.Second) +func (h *Headscale) pingDB(ctx context.Context) error { + ctx, cancel := context.WithTimeout(ctx, time.Second) defer cancel() db, err := h.db.DB() if err != nil {