Tweak NATS startup and readiness checking (#3523)

Signed-off-by: Neil Alexander <git@neilalexander.dev>

Signed-off-by: Neil Alexander <git@neilalexander.dev>
Co-authored-by: Neil Alexander <neilalexander@users.noreply.github.com>
This commit is contained in:
Neil 2025-02-03 21:01:56 +00:00 committed by GitHub
parent ad22d950dd
commit 06e25ca5ca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -66,10 +66,8 @@ func (s *NATSInstance) Prepare(process *process.ProcessContext, cfg *config.JetS
if !cfg.NoLog { if !cfg.NoLog {
s.SetLogger(NewLogAdapter(), opts.Debug, opts.Trace) s.SetLogger(NewLogAdapter(), opts.Debug, opts.Trace)
} }
go func() { process.ComponentStarted()
process.ComponentStarted() go s.Start()
s.Start()
}()
go func() { go func() {
<-process.WaitForShutdown() <-process.WaitForShutdown()
s.Shutdown() s.Shutdown()
@ -77,7 +75,12 @@ func (s *NATSInstance) Prepare(process *process.ProcessContext, cfg *config.JetS
process.ComponentFinished() process.ComponentFinished()
}() }()
if !s.ReadyForConnections(time.Second * 60) { if !s.ReadyForConnections(time.Second * 60) {
logrus.Fatalln("NATS did not start in time") logrus.Fatalln("NATS did not start in time, shutting down")
process.ShutdownDendrite()
s.Shutdown()
s.WaitForShutdown()
process.ComponentFinished()
return nil, nil
} }
} }