Migrate deployment to Gitea Actions and Portainer
This commit is contained in:
@@ -4,8 +4,9 @@ import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/dustinpianalto/geeksbot/pkg/database/migrations"
|
||||
"gitea.wayfinderak.com/wayfinderak/geeksbot/pkg/database/migrations"
|
||||
"github.com/golang-migrate/migrate/v4"
|
||||
"github.com/golang-migrate/migrate/v4/database/postgres"
|
||||
bindata "github.com/golang-migrate/migrate/v4/source/go_bindata"
|
||||
@@ -20,18 +21,26 @@ var (
|
||||
RequestService requestService
|
||||
PatreonService patreonService
|
||||
ServerService serverService
|
||||
RaffleService raffleService
|
||||
)
|
||||
|
||||
func ConnectDatabase(dbConnString string) {
|
||||
var err error
|
||||
db, err = sql.Open("postgres", dbConnString)
|
||||
if err != nil {
|
||||
log.Fatal(fmt.Errorf("Can't connect to the database: %w", err))
|
||||
log.Fatal(fmt.Errorf("can't connect to the database: %w", err))
|
||||
}
|
||||
|
||||
db.SetMaxOpenConns(5)
|
||||
db.SetMaxIdleConns(2)
|
||||
db.SetConnMaxLifetime(30 * time.Minute)
|
||||
db.SetConnMaxIdleTime(5 * time.Minute)
|
||||
|
||||
if err = db.Ping(); err != nil {
|
||||
log.Fatal(fmt.Errorf("can't ping the database: %w", err))
|
||||
}
|
||||
|
||||
log.Println("Database Connected.")
|
||||
db.SetMaxOpenConns(75)
|
||||
db.SetMaxIdleConns(5)
|
||||
db.SetConnMaxLifetime(300)
|
||||
initServices()
|
||||
log.Println("Services Initialized")
|
||||
}
|
||||
@@ -73,4 +82,5 @@ func initServices() {
|
||||
PatreonService = patreonService{db: db}
|
||||
RequestService = requestService{db: db}
|
||||
ServerService = serverService{db: db}
|
||||
RaffleService = raffleService{db: db}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user