From 11c5ba2515548a3d34af3f65668cf64a401c5da7 Mon Sep 17 00:00:00 2001 From: Neil Twigg Date: Tue, 16 Jul 2024 14:33:48 +0100 Subject: [PATCH] Rename `lameDuckMode` to `LameDuckShutdown` so that it is accessible when embedding NATS Otherwise this function isn't available when embedding the NATS Server, where using `SIGUSR2` likely isn't appropriate. Signed-off-by: Neil Twigg --- server/server.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/server/server.go b/server/server.go index 4f26b86a67..be21987bd9 100644 --- a/server/server.go +++ b/server/server.go @@ -4150,6 +4150,16 @@ func (s *Server) isLameDuckMode() bool { return s.ldm } +// LameDuckShutdown will perform a lame duck shutdown of NATS, whereby +// the client listener is closed, existing client connections are +// kicked, Raft leaderships are transferred, JetStream is shutdown +// and then finally shutdown the the NATS Server itself. +// This function blocks and will not return until the NATS Server +// has completed the entire shutdown operation. +func (s *Server) LameDuckShutdown() { + s.lameDuckMode() +} + // This function will close the client listener then close the clients // at some interval to avoid a reconnect storm. // We will also transfer any raft leaders and shutdown JetStream.