service: fix ordering #111

Merged
vtolstov merged 1 commits from config into v3 2022-03-30 15:51:28 +03:00
Showing only changes of commit 35162a82a4 - Show all commits

View File

@ -252,16 +252,6 @@ func (s *service) Start() error {
config := s.opts config := s.opts
s.RUnlock() 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 { for _, cfg := range s.opts.Configs {
if cfg.Options().Struct == nil { if cfg.Options().Struct == nil {
// skip config as the struct not passed // 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 { if len(s.opts.Servers) == 0 {
return fmt.Errorf("cant start nil server") return fmt.Errorf("cant start nil server")
} }