mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-10 09:02:30 +08:00
Pass the req context when pinging the DB
This commit is contained in:
parent
4527801d48
commit
f23e9dc235
2 changed files with 3 additions and 3 deletions
2
api.go
2
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
|
||||
|
|
4
db.go
4
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 {
|
||||
|
|
Loading…
Reference in a new issue