diff --git a/backend/init/db/db.go b/backend/init/db/db.go index f1fccda73..64b67b3f4 100644 --- a/backend/init/db/db.go +++ b/backend/init/db/db.go @@ -2,9 +2,11 @@ package db import ( "fmt" + "os" + "time" + "gorm.io/driver/sqlite" "gorm.io/gorm" - "os" "github.com/1Panel-dev/1Panel/backend/global" ) @@ -28,6 +30,15 @@ func Init() { if err != nil { panic(err) } + _ = db.Exec("PRAGMA journal_mode = WAL;") + sqlDB, dbError := db.DB() + if dbError != nil { + panic(err) + } + sqlDB.SetConnMaxIdleTime(10) + sqlDB.SetMaxOpenConns(100) + sqlDB.SetConnMaxLifetime(time.Hour) + global.DB = db global.LOG.Info("init db successfully") }