File tree Expand file tree Collapse file tree 1 file changed +14
-10
lines changed Expand file tree Collapse file tree 1 file changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -30,16 +30,6 @@ func ConnectDatabase() error {
3030 Logger : gorm_zerolog .New (),
3131 }
3232
33- // logger.New(
34- // golog.New(os.Stdout, "\r\n", golog.LstdFlags),
35- // logger.Config{
36- // SlowThreshold: time.Millisecond,
37- // LogLevel: logger.Error,
38- // IgnoreRecordNotFoundError: true,
39- // Colorful: true,
40- // },
41- // ),
42-
4333 // Check with database driver to use. If DB_HOST is set, assume postgresql
4434 _ , ok := os .LookupEnv ("DB_HOST" )
4535 if ok {
@@ -66,6 +56,20 @@ func ConnectDatabase() error {
6656 return err
6757 }
6858
59+ sqlDB , err := db .DB ()
60+ if err != nil {
61+ return err
62+ }
63+
64+ // Get new connections after one hour
65+ sqlDB .SetConnMaxLifetime (time .Hour )
66+
67+ // This is done to prevent SQLITE_BUSY errors.
68+ // If you have ideas how to improve this, you are very welcome to open an issue or a PR. Thank you!
69+ sqlDB .SetMaxIdleConns (1 )
70+ sqlDB .SetMaxOpenConns (1 )
71+
6972 DB = db
73+
7074 return nil
7175}
You can’t perform that action at this time.
0 commit comments