From 8faf5373271baf68b5083d7a88e30c7e0adb4d6a Mon Sep 17 00:00:00 2001 From: Philipp Mieden Date: Wed, 20 Jan 2021 16:54:23 +0100 Subject: [PATCH] exit cleanly by default if no cleanup function has been provided --- reloader.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/reloader.go b/reloader.go index a202952..051b423 100644 --- a/reloader.go +++ b/reloader.go @@ -65,12 +65,14 @@ func NewCertReloader(certPath, keyPath string, logFile *os.File, cleanup func()) // run custom cleanup func if available if cleanup != nil { - cleanup() - } - // keep running. - // it is up to the caller of simplecert.NewCertReloader() - // to decide what to do now + // execute the cleanup function supplied by the user + // if you want to keep the program running at this point, supply a cleanup function that does nothing. + cleanup() + } else { + // if no cleanup function has been specified: exit cleanly + os.Exit(0) + } } } }()