diff options
Diffstat (limited to 'backend/database/database.go')
| -rw-r--r-- | backend/database/database.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/backend/database/database.go b/backend/database/database.go index 5a55c21..25570f7 100644 --- a/backend/database/database.go +++ b/backend/database/database.go | |||
| @@ -4,6 +4,7 @@ import ( | |||
| 4 | "database/sql" | 4 | "database/sql" |
| 5 | "fmt" | 5 | "fmt" |
| 6 | "os" | 6 | "os" |
| 7 | "time" | ||
| 7 | 8 | ||
| 8 | _ "github.com/lib/pq" | 9 | _ "github.com/lib/pq" |
| 9 | ) | 10 | ) |
| @@ -26,6 +27,9 @@ func ConnectDB() { | |||
| 26 | if err = db.Ping(); err != nil { | 27 | if err = db.Ping(); err != nil { |
| 27 | panic(err) | 28 | panic(err) |
| 28 | } | 29 | } |
| 30 | db.SetMaxOpenConns(50) | ||
| 31 | db.SetMaxIdleConns(2) | ||
| 32 | db.SetConnMaxLifetime(time.Minute * 5) | ||
| 29 | DB = db | 33 | DB = db |
| 30 | fmt.Println("Successfully connected to database!") | 34 | fmt.Println("Successfully connected to database!") |
| 31 | } | 35 | } |