Tweak NATS startup and readiness checking

Signed-off-by: Neil Alexander <git@neilalexander.dev>
This commit is contained in:
Neil Alexander 2025-02-03 20:10:51 +00:00
parent ad22d950dd
commit 1b2dcde184
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944

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
} }
} }