restart server on Init

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2020-10-16 16:15:39 +03:00
parent e6f7ceb900
commit 2f6c352a57

11
grpc.go
View File

@ -157,12 +157,23 @@ func (g *grpcServer) configure(opts ...server.Option) error {
} }
g.rsvc = nil g.rsvc = nil
restart := false
if g.started {
restart = true
if err := g.Stop(); err != nil {
return err
}
}
g.srv = grpc.NewServer(gopts...) g.srv = grpc.NewServer(gopts...)
if v, ok := g.opts.Context.Value(reflectionKey{}).(bool); ok { if v, ok := g.opts.Context.Value(reflectionKey{}).(bool); ok {
g.reflection = v g.reflection = v
} }
if restart {
return g.Start()
}
return nil return nil
} }