Skip to content

Commit

Permalink
Tweak NATS startup and readiness checking (#3523)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
neilalexander and neilalexander authored Feb 3, 2025
1 parent ad22d95 commit 06e25ca
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 @@ -66,18 +66,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 06e25ca

Please sign in to comment.