make SetupDatabase returns an error and use PingContext with timeout

This commit is contained in:
Bruno Sousa
2020-04-15 16:18:51 +02:00
parent 11ea1c13bd
commit c64b4d0d39
3 changed files with 18 additions and 21 deletions

View File

@@ -30,7 +30,10 @@ func main() {
devMode := os.Getenv("DEVELOPMENT") == "1"
db := database.SetupDatabase()
db, err := database.SetupDatabase()
if err != nil {
log.Panicf("Could not connect to database: %s\n", err)
}
defer db.Close()
// Migrate database
@@ -96,5 +99,5 @@ func main() {
}
log.Fatal(http.ListenAndServe(":"+apiListenUrl.Port(), rootRouter))
log.Panic(http.ListenAndServe(":"+apiListenUrl.Port(), rootRouter))
}