exit cleanly by default if no cleanup function has been provided

This commit is contained in:
Philipp Mieden 2021-01-20 16:54:23 +01:00
parent b441d911f8
commit 8faf537327

View File

@ -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)
}
}
}
}()