Files
crawlab/core/apps/utils.go
2024-11-23 10:51:46 +08:00

29 lines
484 B
Go

package apps
import (
"fmt"
"github.com/apex/log"
"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 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
}