init cmd and logger options on service init
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
c44a82a8cb
commit
4233a4b673
19
service.go
19
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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user