All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 2m11s
32 lines
583 B
Go
32 lines
583 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"log"
|
|
"time"
|
|
|
|
"git.kanopo.dev/rhythm/rhythm-backend/internal/config"
|
|
"github.com/jackc/pgx/v5/pgxpool"
|
|
)
|
|
|
|
func main() {
|
|
cfg := config.Load()
|
|
ctx := context.Background()
|
|
pool, err := pgxpool.New(ctx, cfg.DbUrl)
|
|
if err != nil {
|
|
log.Fatalf("Error creatin the db pool:%v\n", err.Error())
|
|
}
|
|
defer pool.Close()
|
|
|
|
{
|
|
ctx, cancel := context.WithTimeout(ctx, time.Second*5)
|
|
defer cancel()
|
|
if err := pool.Ping(ctx); err != nil {
|
|
log.Fatalf("ping to db failed %v", err.Error())
|
|
}
|
|
log.Printf("successfully connected to database")
|
|
|
|
}
|
|
|
|
}
|