fix: compiling issue

This commit is contained in:
Marvin Zhang
2024-07-12 20:05:14 +08:00
parent 0c8b42145a
commit cbdfbf8d1d
4 changed files with 42 additions and 50 deletions

View File

@@ -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
View 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
})
}

View File

@@ -1,43 +0,0 @@
package server
import (
"github.com/crawlab-team/crawlab/core/interfaces"
)
type Option func(svr interfaces.GrpcServer)
func WithConfigPath(path string) Option {
return func(svr interfaces.GrpcServer) {
svr.SetConfigPath(path)
}
}
func WithAddress(address interfaces.Address) Option {
return func(svr interfaces.GrpcServer) {
svr.SetAddress(address)
}
}
type NodeServerOption func(svr *NodeServer)
func WithServerNodeServerService(server interfaces.GrpcServer) NodeServerOption {
return func(svr *NodeServer) {
svr.server = server
}
}
type TaskServerOption func(svr *TaskServer)
func WithServerTaskServerService(server interfaces.GrpcServer) TaskServerOption {
return func(svr *TaskServer) {
svr.server = server
}
}
type MessageServerOption func(svr *MessageServer)
func WithServerMessageServerService(server interfaces.GrpcServer) MessageServerOption {
return func(svr *MessageServer) {
svr.server = server
}
}

View File

@@ -327,12 +327,6 @@ func newMasterServiceV2() (res *MasterServiceV2, err error) {
stopOnError: false,
}
// server options
var serverOpts []server.Option
if svc.address != nil {
serverOpts = append(serverOpts, server.WithAddress(svc.address))
}
// node config service
svc.cfgSvc = config.GetNodeConfigService()