Make max DB connection attempts a constant

This commit is contained in:
Aaron Greenberg 2017-12-12 22:32:00 -05:00
parent 66b116ecb2
commit 0df9e7075c

View File

@ -61,6 +61,8 @@ import (
_ "github.com/coreos/clair/ext/vulnsrc/ubuntu"
)
const maxDBConnectionAttempts = 20
func waitForSignals(signals ...os.Signal) {
interrupts := make(chan os.Signal, 1)
signal.Notify(interrupts, signals...)
@ -134,8 +136,7 @@ func Boot(config *Config) {
// Open database
var db database.Datastore
var dbError error
maxConnectionAttempts := 20
for attempts := 1; attempts <= maxConnectionAttempts; attempts++ {
for attempts := 1; attempts <= maxDBConnectionAttempts; attempts++ {
db, dbError = database.Open(config.Database)
if dbError == nil {
break
@ -143,7 +144,6 @@ func Boot(config *Config) {
log.Error(dbError);
time.Sleep(time.Duration(attempts) * time.Second)
}
if dbError != nil {
log.Fatal(dbError)
}