mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-27 12:28:40 +08:00
33 lines
569 B
Go
33 lines
569 B
Go
|
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"
|
||
|
"zero/ngin"
|
||
|
"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,
|
||
|
}
|
||
|
|
||
|
engine := ngin.MustNewEngine(c.NgConf)
|
||
|
defer engine.Stop()
|
||
|
|
||
|
handler.RegisterHandlers(engine, ctx)
|
||
|
engine.Start()
|
||
|
}
|