5
5
package routers
6
6
7
7
import (
8
+ "context"
8
9
"strings"
9
10
"time"
10
11
@@ -53,11 +54,11 @@ func NewServices() {
53
54
}
54
55
55
56
// In case of problems connecting to DB, retry connection. Eg, PGSQL in Docker Container on Synology
56
- func initDBEngine () (err error ) {
57
+ func initDBEngine (ctx context. Context ) (err error ) {
57
58
log .Info ("Beginning ORM engine initialization." )
58
59
for i := 0 ; i < setting .Database .DBConnectRetries ; i ++ {
59
60
log .Info ("ORM engine initialization attempt #%d/%d..." , i + 1 , setting .Database .DBConnectRetries )
60
- if err = models .NewEngine (migrations .Migrate ); err == nil {
61
+ if err = models .NewEngine (ctx , migrations .Migrate ); err == nil {
61
62
break
62
63
} else if i == setting .Database .DBConnectRetries - 1 {
63
64
return err
@@ -71,9 +72,9 @@ func initDBEngine() (err error) {
71
72
}
72
73
73
74
// GlobalInit is for global configuration reload-able.
74
- func GlobalInit () {
75
+ func GlobalInit (ctx context. Context ) {
75
76
setting .NewContext ()
76
- if err := git .Init (); err != nil {
77
+ if err := git .Init (ctx ); err != nil {
77
78
log .Fatal ("Git module init failed: %v" , err )
78
79
}
79
80
setting .CheckLFSVersion ()
@@ -88,7 +89,7 @@ func GlobalInit() {
88
89
highlight .NewContext ()
89
90
external .RegisterParsers ()
90
91
markup .Init ()
91
- if err := initDBEngine (); err == nil {
92
+ if err := initDBEngine (ctx ); err == nil {
92
93
log .Info ("ORM engine initialization successful!" )
93
94
} else {
94
95
log .Fatal ("ORM engine initialization failed: %v" , err )
0 commit comments