From 4b4c5086b6cd195f758d3064ef8ac41affbbd696 Mon Sep 17 00:00:00 2001 From: Luca Weiss Date: Fri, 28 Jun 2019 19:29:14 +0200 Subject: [PATCH] worker: test db connection before starting worker Without this, a misconfigured database string would not be noticed (immediately), but now the worker aborts directly if it can't access the database. --- worker/main.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/worker/main.go b/worker/main.go index 4d9d202..77355a0 100644 --- a/worker/main.go +++ b/worker/main.go @@ -47,6 +47,9 @@ func main() { if err != nil { panic(err) } + if err := db.Ping(); err != nil { + log.Fatalf("Failed to open a database connection: %v", err) + } clusterRedis := conf("builds.sr.ht", "redis") broker := celery.NewRedisCeleryBroker(clusterRedis) -- 2.38.5