Browse Source

catch error on call setup on serv command (#932)

Lunny Xiao 2 years ago
parent
commit
be55460b63
1 changed files with 5 additions and 3 deletions
  1. 5 3
      cmd/serve.go

+ 5 - 3
cmd/serve.go

@@ -47,7 +47,7 @@ var CmdServ = cli.Command{
47 47
 	},
48 48
 }
49 49
 
50
-func setup(logPath string) {
50
+func setup(logPath string) error {
51 51
 	setting.NewContext()
52 52
 	log.NewGitLogger(filepath.Join(setting.LogRootPath, logPath))
53 53
 
@@ -60,7 +60,7 @@ func setup(logPath string) {
60 60
 		}
61 61
 	}
62 62
 
63
-	models.SetEngine()
63
+	return models.SetEngine()
64 64
 }
65 65
 
66 66
 func parseCmd(cmd string) (string, string) {
@@ -146,7 +146,9 @@ func runServ(c *cli.Context) error {
146 146
 		setting.CustomConf = c.String("config")
147 147
 	}
148 148
 
149
-	setup("serv.log")
149
+	if err := setup("serv.log"); err != nil {
150
+		fail("System init failed", fmt.Sprintf("setup: %v", err))
151
+	}
150 152
 
151 153
 	if setting.SSH.Disabled {
152 154
 		println("Gitea: SSH has been disabled")