Files
GL/cmd/healthcheck/main.go
T

31 lines
573 B
Go

package main
import (
"context"
"flag"
"os"
"time"
"gl/infrastructure/config"
"gl/infrastructure/postgres"
)
func main() {
configPath := flag.String("conf", "/app/config.toml", "path to the GL TOML configuration file")
flag.Parse()
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
cfg, err := config.Load(*configPath)
if err != nil {
os.Exit(1)
}
database, err := postgres.Open(ctx, cfg.Database)
if err != nil {
os.Exit(1)
}
defer database.Close()
if err := database.Ping(ctx); err != nil {
os.Exit(1)
}
}