jzero-io / jzero

Used to create project from templates and generate Server/Client code by proto and api file.
https://jzero.jaronnie.com/
MIT License
29 stars 2 forks source link

持续增强项目规范 #28

Open jaronnie opened 5 days ago

jaronnie commented 3 days ago
// shutdown listener
    wailExit := proc.AddShutdownListener(svcCtx.Custom.Stop)

    eg := errgroup.Group{}
    eg.Go(func() error {
        fmt.Printf("Starting rpc server at %s...\n", svcCtx.Config.Zrpc.ListenOn)
        fmt.Printf("Starting gateway server at %s:%d...\n", svcCtx.Config.Gateway.Host, svcCtx.Config.Gateway.Port)
        group.Start()
        return nil
    })

    // add your custom logic in custom.Do()
    eg.Go(func() error {
        svcCtx.Custom.Start()
        return nil
    })

    if err := eg.Wait(); err != nil {
        panic(err)
    }

    wailExit()
jaronnie commented 3 days ago

define a custom struct in svc.ServiceContext. And add custom.Start and Stop method

jaronnie commented 3 days ago

https://github.com/jzero-io/templates 的 gateway 分支进行规范化