check for nil cmd

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2020-09-14 12:58:51 +03:00
parent 2d1e6db9fd
commit d59db9df16

View File

@ -43,6 +43,7 @@ func (s *service) Init(opts ...Option) {
} }
s.once.Do(func() { s.once.Do(func() {
if s.opts.Cmd != nil {
// set cmd name // set cmd name
if len(s.opts.Cmd.App().Name) == 0 { if len(s.opts.Cmd.App().Name) == 0 {
s.opts.Cmd.App().Name = s.Server().Options().Name s.opts.Cmd.App().Name = s.Server().Options().Name
@ -63,6 +64,7 @@ func (s *service) Init(opts ...Option) {
); err != nil { ); err != nil {
logger.Fatalf("[cmd] init failed: %v", err) logger.Fatalf("[cmd] init failed: %v", err)
} }
}
}) })
if s.opts.Registry != nil { if s.opts.Registry != nil {