summaryrefslogtreecommitdiffstats
path: root/modules/doctor
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-11-07 11:11:27 +0800
committerGitHub <noreply@github.com>2021-11-07 11:11:27 +0800
commit69b61d437357235700306f28d22d21acc39bb2b5 (patch)
tree33af1d4d797b428556a323837fcc3eda38a54479 /modules/doctor
parentc9110eb5e4657e018695f084f37e1b423939e9e0 (diff)
downloadgitea-69b61d437357235700306f28d22d21acc39bb2b5.tar.gz
gitea-69b61d437357235700306f28d22d21acc39bb2b5.zip
Fix bug on admin subcommand (#17533)
* Fix bug on admin subcommand * Add signals for all initDB Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'modules/doctor')
-rw-r--r--modules/doctor/doctor.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/modules/doctor/doctor.go b/modules/doctor/doctor.go
index 9a05e828f4..6451788f9d 100644
--- a/modules/doctor/doctor.go
+++ b/modules/doctor/doctor.go
@@ -5,6 +5,7 @@
package doctor
import (
+ "context"
"fmt"
"sort"
"strings"
@@ -42,12 +43,12 @@ func (w *wrappedLevelLogger) Log(skip int, level log.Level, format string, v ...
}, v...)...)
}
-func initDBDisableConsole(disableConsole bool) error {
+func initDBDisableConsole(ctx context.Context, disableConsole bool) error {
setting.NewContext()
setting.InitDBConfig()
setting.NewXORMLogService(disableConsole)
- if err := db.InitEngine(); err != nil {
+ if err := db.InitEngine(ctx); err != nil {
return fmt.Errorf("models.SetEngine: %v", err)
}
return nil
@@ -57,7 +58,7 @@ func initDBDisableConsole(disableConsole bool) error {
var Checks []*Check
// RunChecks runs the doctor checks for the provided list
-func RunChecks(logger log.Logger, autofix bool, checks []*Check) error {
+func RunChecks(ctx context.Context, logger log.Logger, autofix bool, checks []*Check) error {
wrappedLogger := log.LevelLoggerLogger{
LevelLogger: &wrappedLevelLogger{logger},
}
@@ -67,7 +68,7 @@ func RunChecks(logger log.Logger, autofix bool, checks []*Check) error {
if !dbIsInit && !check.SkipDatabaseInitialization {
// Only open database after the most basic configuration check
setting.EnableXORMLog = false
- if err := initDBDisableConsole(true); err != nil {
+ if err := initDBDisableConsole(ctx, true); err != nil {
logger.Error("Error whilst initializing the database: %v", err)
logger.Error("Check if you are using the right config file. You can use a --config directive to specify one.")
return nil