moved to psql pool closes #99
This commit is contained in:
11
main.go
11
main.go
@@ -1,12 +1,12 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
|
||||
"github.com/charmbracelet/log"
|
||||
_ "github.com/lib/pq"
|
||||
|
||||
"git.andr3h3nriqu3s.com/andr3/fyp/logic/db"
|
||||
. "git.andr3h3nriqu3s.com/andr3/fyp/logic/models"
|
||||
. "git.andr3h3nriqu3s.com/andr3/fyp/logic/tasks"
|
||||
. "git.andr3h3nriqu3s.com/andr3/fyp/logic/tasks/runner"
|
||||
@@ -23,23 +23,18 @@ const (
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
psqlInfo := fmt.Sprintf("host=%s port=%d user=%s "+
|
||||
"password=%s dbname=%s sslmode=disable",
|
||||
host, port, user, password, dbname)
|
||||
|
||||
db, err := sql.Open("postgres", psqlInfo)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
db := db.StartUp(psqlInfo)
|
||||
defer db.Close()
|
||||
log.Info("Starting server on :5002!")
|
||||
|
||||
config := LoadConfig()
|
||||
log.Info("Config loaded!", "config", config)
|
||||
config.GenerateToken(db)
|
||||
|
||||
db.SetMaxOpenConns(config.DbInfo.MaxConnections)
|
||||
|
||||
StartRunners(db, config)
|
||||
|
||||
//TODO check if file structure exists to save data
|
||||
|
||||
Reference in New Issue
Block a user