1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- package main
- import (
- "Cold_Logistic/internal/pkg/common/global"
- "Cold_Logistic/internal/pkg/common/options"
- "Cold_Logistic/internal/server/adapter"
- "fmt"
- "gogs.baozhida.cn/Cold_Logistic_libs/pkg/app"
- "gogs.baozhida.cn/Cold_Logistic_libs/pkg/contrib/core/middleware"
- "math/rand"
- "runtime"
- "time"
- "gogs.baozhida.cn/Cold_Logistic_libs/pkg/app/server"
- "gogs.baozhida.cn/Cold_Logistic_libs/pkg/app/toolkit"
- )
- func init() {
- rand.Seed(time.Now().UTC().UnixNano())
- runtime.GOMAXPROCS(runtime.NumCPU())
- }
- // nohup ./Cold_Logistic run --profile=../configs/test.yaml &
- func main() {
- opt := options.NewOptions()
- s := server.NewServer(
- server.WithCustomConfigStructPtr(opt),
- server.WithOnConfigFileChange(opt),
- server.WithHttpServer(
- server.WithGlobalMiddleware(
- middleware.AddRequestID(),
- middleware.Limit(10000, 5*1000),
- ),
- server.WithDefaultHealthApi(),
- server.WithDefaultVersionApi(),
- server.WithDefaultMetricApi(""),
- server.WithDefaultPprofApi(""),
- server.WithHTTPApi(adapter.HttpRoutes()),
- ),
- server.WithCronJob(server.WithCronApi(adapter.RegisterCron())),
- server.WithSelfMonitor(),
- server.WithComponent(global.NewCommonConnectsRepo(opt)),
- )
- a := app.NewApp("server")
- a.AddCommand(
- s.NewRunCommand(),
- toolkit.NewVersionCommand(a.GetFileName()),
- )
- if err := a.Run(); err != nil {
- panic(fmt.Sprintf("Error:%v\n", err))
- }
- }
|