Use a linear backoff when connecting to DB

Closes #159
pull/487/head
Aaron Greenberg 7 years ago
parent 39f00cd756
commit 66b116ecb2

@ -132,10 +132,22 @@ func Boot(config *Config) {
st := stopper.NewStopper()
// Open database
db, err := database.Open(config.Database)
if err != nil {
log.Fatal(err)
var db database.Datastore
var dbError error
maxConnectionAttempts := 20
for attempts := 1; attempts <= maxConnectionAttempts; attempts++ {
db, dbError = database.Open(config.Database)
if dbError == nil {
break
}
log.Error(dbError);
time.Sleep(time.Duration(attempts) * time.Second)
}
if dbError != nil {
log.Fatal(dbError)
}
defer db.Close()
// Start notifier

Loading…
Cancel
Save