Skip to content

Commit

Permalink
Tweak NATS startup and readiness checking
Browse files Browse the repository at this point in the history
  • Loading branch information
neilalexander committed Feb 11, 2025
1 parent ff1449e commit 543eeee
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions setup/jetstream/nats.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,21 @@ func (s *NATSInstance) Prepare(process *process.ProcessContext, cfg *config.JetS
if !cfg.NoLog {
s.SetLogger(NewLogAdapter(), opts.Debug, opts.Trace)
}
go func() {
process.ComponentStarted()
s.Start()
}()
process.ComponentStarted()
go s.Start()
go func() {
<-process.WaitForShutdown()
s.Shutdown()
s.WaitForShutdown()
process.ComponentFinished()
}()
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
}
}

Expand Down

0 comments on commit 543eeee

Please sign in to comment.