go-zero/example/graceful/etcd/api/graceful.go

33 lines
569 B
Go
Raw Normal View History

2020-07-26 17:09:05 +08:00
package main
import (
"flag"
"zero/core/conf"
"zero/example/graceful/etcd/api/config"
"zero/example/graceful/etcd/api/handler"
"zero/example/graceful/etcd/api/svc"
2020-07-31 11:14:48 +08:00
"zero/rest"
2020-07-26 17:09:05 +08:00
"zero/rpcx"
)
var configFile = flag.String("f", "etc/graceful-api.json", "the config file")
func main() {
flag.Parse()
var c config.Config
conf.MustLoad(*configFile, &c)
client := rpcx.MustNewClient(c.Rpc)
ctx := &svc.ServiceContext{
Client: client,
}
2020-07-31 11:14:48 +08:00
engine := rest.MustNewEngine(c.RtConf)
2020-07-26 17:09:05 +08:00
defer engine.Stop()
handler.RegisterHandlers(engine, ctx)
engine.Start()
}