Merge pull request #111 from unistack-org/config

service: fix ordering
This commit is contained in:
Василий Толстов 2022-03-30 15:51:27 +03:00 committed by GitHub
commit 25c551411b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -252,16 +252,6 @@ func (s *service) Start() error {
config := s.opts
s.RUnlock()
if config.Loggers[0].V(logger.InfoLevel) {
config.Loggers[0].Infof(s.opts.Context, "starting [service] %s version %s", s.Options().Name, s.Options().Version)
}
for _, fn := range s.opts.BeforeStart {
if err = fn(s.opts.Context); err != nil {
return err
}
}
for _, cfg := range s.opts.Configs {
if cfg.Options().Struct == nil {
// skip config as the struct not passed
@ -273,6 +263,16 @@ func (s *service) Start() error {
}
}
for _, fn := range s.opts.BeforeStart {
if err = fn(s.opts.Context); err != nil {
return err
}
}
if config.Loggers[0].V(logger.InfoLevel) {
config.Loggers[0].Infof(s.opts.Context, "starting [service] %s version %s", s.Options().Name, s.Options().Version)
}
if len(s.opts.Servers) == 0 {
return fmt.Errorf("cant start nil server")
}