Fix healthcheck
This commit is contained in:
parent
36c04e656d
commit
f7981715db
4 changed files with 53 additions and 14 deletions
29
cmd/api.go
29
cmd/api.go
|
@ -5,6 +5,7 @@ import (
|
|||
"fmt"
|
||||
"log"
|
||||
|
||||
"git.agecem.com/agecem/bottin-agenda/data"
|
||||
"git.agecem.com/agecem/bottin-agenda/handlers"
|
||||
bottindata "git.agecem.com/agecem/bottin/v5/data"
|
||||
"github.com/labstack/echo/v4"
|
||||
|
@ -27,16 +28,6 @@ var apiCmd = &cobra.Command{
|
|||
apiKey = viper.GetString("api.key")
|
||||
apiPort = viper.GetInt("api.port")
|
||||
|
||||
/*
|
||||
dbConnection := data.PostgresConnection{
|
||||
User: viper.GetString("db.user"),
|
||||
Password: viper.GetString("db.password"),
|
||||
Host: viper.GetString("db.host"),
|
||||
Database: viper.GetString("db.database"),
|
||||
Port: viper.GetInt("db.port"),
|
||||
}
|
||||
*/
|
||||
|
||||
bottinApiKey := viper.GetString("bottin.api.key")
|
||||
bottinApiHost := viper.GetString("bottin.api.host")
|
||||
bottinApiProtocol := viper.GetString("bottin.api.protocol")
|
||||
|
@ -72,10 +63,24 @@ var apiCmd = &cobra.Command{
|
|||
|
||||
bottinHealthResponse, err := bottinConnection.GetHealth()
|
||||
if err != nil {
|
||||
log.Fatalf("bottinConnection.GetHealth(): %s", err)
|
||||
log.Fatalf("[bottin] bottinConnection.GetHealth(): %s", err)
|
||||
}
|
||||
|
||||
log.Println(bottinHealthResponse)
|
||||
log.Println("[bottin] ok: ", bottinHealthResponse)
|
||||
|
||||
// Check database is ready
|
||||
|
||||
dataClient, err := data.NewDataClientFromViper()
|
||||
if err != nil {
|
||||
log.Fatalf("[bottin-agenda db] data.NewDataclientFromViper(): %s", err)
|
||||
}
|
||||
defer dataClient.DB.Close()
|
||||
|
||||
if err := dataClient.DB.Ping(); err != nil {
|
||||
log.Fatalf("[bottin-agenda db] dataClient.DB.Ping(): %s", err)
|
||||
} else {
|
||||
log.Println("[bottin-agenda db] ok")
|
||||
}
|
||||
|
||||
// Execution
|
||||
|
||||
|
|
Reference in a new issue