From 4233a4b67306b3961df3a4f4a58eb020c0b76da0 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Fri, 13 Nov 2020 14:52:19 +0300 Subject: [PATCH] init cmd and logger options on service init Signed-off-by: Vasiliy Tolstov --- service.go | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/service.go b/service.go index d8b45b04..bba6bfd5 100644 --- a/service.go +++ b/service.go @@ -36,8 +36,6 @@ func (s *service) Name() string { // which parses command line flags. cmd.Init is only called // on first Init. func (s *service) Init(opts ...Option) error { - //var once sync.Once - // process options for _, o := range opts { o(&s.opts) @@ -49,13 +47,18 @@ func (s *service) Init(opts ...Option) error { s.opts.Cmd.App().Name = s.Server().Options().Name } - //once.Do(func() { // Initialise the command options - // if err := s.opts.Cmd.Init(); err != nil { - // logger.Fatal(err) - //return err - // } - //}) + if err := s.opts.Cmd.Init(); err != nil { + return err + } + } + + if s.opts.Logger != nil { + if err := s.opts.Logger.Init( + logger.WithContext(s.opts.Context), + ); err != nil { + return err + } } if s.opts.Registry != nil {