aboutsummaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
authorArda Serdar Pektezol <1669855+pektezol@users.noreply.github.com>2023-12-15 11:24:07 +0300
committerGitHub <noreply@github.com>2023-12-15 11:24:07 +0300
commitc4d93c99a1692f4eec066e9797b076e7d980973d (patch)
tree541785bc9536520efb05f1d0f5c3c311cf0b808c /backend
parentdocs: add missing param (#59) (diff)
downloadlphub-c4d93c99a1692f4eec066e9797b076e7d980973d.tar.gz
lphub-c4d93c99a1692f4eec066e9797b076e7d980973d.tar.bz2
lphub-c4d93c99a1692f4eec066e9797b076e7d980973d.zip
fix: set db connection limits (#140)
Diffstat (limited to 'backend')
-rw-r--r--backend/database/database.go4
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}