From 2f1a61fe400f35a632d912ec0b66d6c9bec68971 Mon Sep 17 00:00:00 2001 From: Robby Zambito Date: Mon, 20 Jan 2025 21:18:18 -0500 Subject: Handle exit gracefully doesn't really work?? --- main.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 63b1a4d..e38169a 100644 --- a/main.go +++ b/main.go @@ -6,6 +6,8 @@ import ( "fmt" "log" "log/slog" + "os" + "os/signal" "runtime" "time" @@ -72,6 +74,10 @@ func main() { log.Fatalf("Error reading from Jetstream: %v", err) } - // Keep the program running - select {} + // Wait for interrupt signal to gracefully shut down + interrupt := make(chan os.Signal, 1) + signal.Notify(interrupt, os.Interrupt) + <-interrupt + + log.Println("Shutting down...") } -- cgit