mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-21 17:21:09 +01:00
fix: compiling issue
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/crawlab-team/crawlab/core/controllers"
|
||||
"github.com/crawlab-team/crawlab/core/interfaces"
|
||||
"github.com/crawlab-team/crawlab/core/middlewares"
|
||||
"github.com/crawlab-team/crawlab/core/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/spf13/viper"
|
||||
"net"
|
||||
@@ -73,7 +74,7 @@ func (app *ApiV2) Start() {
|
||||
}
|
||||
|
||||
func (app *ApiV2) Wait() {
|
||||
DefaultWait()
|
||||
utils.DefaultWait()
|
||||
}
|
||||
|
||||
func (app *ApiV2) Stop() {
|
||||
|
||||
40
core/apps/utils.go
Normal file
40
core/apps/utils.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package apps
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/apex/log"
|
||||
"github.com/crawlab-team/crawlab/core/utils"
|
||||
"github.com/crawlab-team/crawlab/trace"
|
||||
)
|
||||
|
||||
func Start(app App) {
|
||||
start(app)
|
||||
}
|
||||
|
||||
func start(app App) {
|
||||
app.Init()
|
||||
go app.Start()
|
||||
app.Wait()
|
||||
app.Stop()
|
||||
}
|
||||
|
||||
func DefaultWait() {
|
||||
utils.DefaultWait()
|
||||
}
|
||||
|
||||
func initModule(name string, fn func() error) (err error) {
|
||||
if err := fn(); err != nil {
|
||||
log.Error(fmt.Sprintf("init %s error: %s", name, err.Error()))
|
||||
_ = trace.TraceError(err)
|
||||
panic(err)
|
||||
}
|
||||
log.Info(fmt.Sprintf("initialized %s successfully", name))
|
||||
return nil
|
||||
}
|
||||
|
||||
func initApp(name string, app App) {
|
||||
_ = initModule(name, func() error {
|
||||
app.Init()
|
||||
return nil
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user