mirror of
https://github.com/foomo/simplecert.git
synced 2026-12-03 19:11:39 +00:00
added optional cleanup func to CertReloader contructor and removed the call to os.Exit after running internal cleanup
This commit is contained in:
+11
-2
@@ -31,7 +31,8 @@ type CertReloader struct {
|
||||
}
|
||||
|
||||
// NewCertReloader returns a new CertReloader instance
|
||||
func NewCertReloader(certPath, keyPath string, logFile *os.File) (*CertReloader, error) {
|
||||
// the optional cleanup func will be called when a syscall.SIGINT, syscall.SIGABRT is received
|
||||
func NewCertReloader(certPath, keyPath string, logFile *os.File, cleanup func()) (*CertReloader, error) {
|
||||
|
||||
// init reloader
|
||||
reloader := &CertReloader{
|
||||
@@ -86,7 +87,15 @@ func NewCertReloader(certPath, keyPath string, logFile *os.File) (*CertReloader,
|
||||
log.Fatal("[FATAL] simplecert: failed to close logfile handle: ", err)
|
||||
}
|
||||
log.Println("[INFO] simplecert: closed logfile handle")
|
||||
os.Exit(0)
|
||||
|
||||
// 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
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
Reference in New Issue
Block a user