api: rename connectDB
This commit is contained in:
parent
645fad6139
commit
58c011030e
@ -7,7 +7,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func connectDB(retriesLeft int) error {
|
func dbConnect(retriesLeft int) error {
|
||||||
con := os.Getenv("POSTGRES")
|
con := os.Getenv("POSTGRES")
|
||||||
logger.Infof("opening connection to postgres: %s", con)
|
logger.Infof("opening connection to postgres: %s", con)
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ func connectDB(retriesLeft int) error {
|
|||||||
if retriesLeft > 0 {
|
if retriesLeft > 0 {
|
||||||
logger.Errorf("cannot talk to postgres, retrying in 10 seconds (%d attempts left): %v", retriesLeft-1, err)
|
logger.Errorf("cannot talk to postgres, retrying in 10 seconds (%d attempts left): %v", retriesLeft-1, err)
|
||||||
time.Sleep(10 * time.Second)
|
time.Sleep(10 * time.Second)
|
||||||
return connectDB(retriesLeft - 1)
|
return dbConnect(retriesLeft - 1)
|
||||||
} else {
|
} else {
|
||||||
logger.Errorf("cannot talk to postgres, last attempt failed: %v", err)
|
logger.Errorf("cannot talk to postgres, last attempt failed: %v", err)
|
||||||
return err
|
return err
|
||||||
|
@ -3,7 +3,7 @@ package main
|
|||||||
func main() {
|
func main() {
|
||||||
exitIfError(loggerCreate())
|
exitIfError(loggerCreate())
|
||||||
exitIfError(configParse())
|
exitIfError(configParse())
|
||||||
exitIfError(connectDB(5))
|
exitIfError(dbConnect(5))
|
||||||
exitIfError(performMigrations())
|
exitIfError(performMigrations())
|
||||||
exitIfError(smtpConfigure())
|
exitIfError(smtpConfigure())
|
||||||
exitIfError(smtpTemplatesLoad())
|
exitIfError(smtpTemplatesLoad())
|
||||||
|
@ -68,7 +68,7 @@ func setupTestDatabase() error {
|
|||||||
os.Setenv("POSTGRES", "postgres://postgres:postgres@localhost/commento_test?sslmode=disable")
|
os.Setenv("POSTGRES", "postgres://postgres:postgres@localhost/commento_test?sslmode=disable")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := connectDB(0); err != nil {
|
if err := dbConnect(0); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user