From bbf44ab586492874b6aafd6f6989e9219da94501 Mon Sep 17 00:00:00 2001 From: Victor Vrantchan Date: Sat, 28 Oct 2017 18:10:11 -0400 Subject: [PATCH] timeout boltdb open connections after 1 second (#279) Closes #267 --- serve.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/serve.go b/serve.go index 754b66b7..6841b2f2 100644 --- a/serve.go +++ b/serve.go @@ -16,6 +16,7 @@ import ( "os" "path/filepath" "strings" + "time" "github.com/fullsailor/pkcs7" "github.com/groob/finalizer/logutil" @@ -546,10 +547,12 @@ func (c *config) setupBolt() { return } dbPath := filepath.Join(c.configPath, "micromdm.db") - c.db, c.err = bolt.Open(dbPath, 0644, nil) - if c.err != nil { + db, err := bolt.Open(dbPath, 0644, &bolt.Options{Timeout: time.Second}) + if err != nil { + c.err = errors.Wrap(err, "opening boltdb") return } + c.db = db } func (c *config) loadPushCerts() {