@@ -29,19 +29,29 @@ func Main() (ok bool) {
2929 // settings
3030 settings := setting .ParseFromEnv ()
3131
32+ // start
33+ errs = Start (settings , params )
34+ if serverError .CheckError (errs ... ) {
35+ return
36+ }
37+
38+ return true
39+ }
40+
41+ func Start (settings * setting.Setting , params param.Params ) (errs []error ) {
3242 // CPU profile
3343 if len (settings .CPUProfileFile ) > 0 {
34- cpuProfileFile , err := StartCPUProfile (settings .CPUProfileFile )
35- if serverError . CheckError ( err ) {
36- return
44+ cpuProfileFile , err := startCPUProfile (settings .CPUProfileFile )
45+ if err != nil {
46+ return [] error { err }
3747 }
38- defer StopCPUProfile (cpuProfileFile )
48+ defer stopCPUProfile (cpuProfileFile )
3949 }
4050
4151 // pid file
4252 if len (settings .PidFile ) > 0 {
4353 errs = writePidFile (settings .PidFile )
44- if serverError . CheckError (errs ... ) {
54+ if len (errs ) > 0 {
4555 return
4656 }
4757 }
@@ -56,11 +66,11 @@ func Main() (ok bool) {
5666
5767 // app
5868 appInst , errs := app .NewApp (params )
59- if serverError . CheckError (errs ... ) {
69+ if len (errs ) > 0 {
6070 return
6171 }
6272 if appInst == nil {
63- serverError . CheckError ( errors .New ("failed to create application instance" ))
73+ errs = [] error { errors .New ("failed to create application instance" )}
6474 return
6575 }
6676
@@ -70,9 +80,5 @@ func Main() (ok bool) {
7080 printAccessibleURLs (appInst .GetAccessibleUrls (false ))
7181 }
7282 errs = appInst .Open ()
73- if serverError .CheckError (errs ... ) {
74- return
75- }
76-
77- return true
83+ return
7884}
0 commit comments