Closed awnumar closed 3 years ago
Sure,
simplecert kicks off a goroutine in the background to close the logfile handle when a termination signal is received.
You can execute additional logic by providing the cleanup hook in the Init call as such:
certReloader, err := simplecert.Init(cfg, func() {
// this function will be called upon receiving the syscall.SIGINT or syscall.SIGABRT signal
// and can be used to stop your backend gracefully
os.Exit(0)
})
if err != nil {
log.Fatal("simplecert init failed: ", err)
}
In this example, your backend would exit after the logfiles have been closed.
In a bigger application you could use this hook to gracefully stop other components of your backend.
That has solved my issue. Thank you.
After simplecert has initialised and my own webserver has started, pressing Ctrl+C to terminate results in the following being outputted and nothing else happening:
You can see where
^C
was pressed. Can you provide guidance as to what could be causing this?