cfssl icon indicating copy to clipboard operation
cfssl copied to clipboard

CFSSL in serve mode should honour SIGHUP properly

Open The-Loeki opened this issue 8 years ago • 1 comments

when CFSSL is serving and you give a kill -HUP the process dies.

It's much nicer to take that signal as reloading config files, certificates & whatnot without actually dying.

The-Loeki avatar Apr 11 '17 13:04 The-Loeki

func handleSIGHUP() {
    // Add code here to reload configuration and certificates.
    // You should replace this comment with your actual reloading logic.
    // This can include reading new config files and updating the running state.

    // Example:
    // ReloadConfigAndCertificates()
}

func main() {
    // ...

    // Create a channel to receive signals
    sigCh := make(chan os.Signal, 1)

    // Notify the signal channel when receiving SIGHUP
    signal.Notify(sigCh, syscall.SIGHUP)

    // Handle signals in a separate goroutine
    go func() {
        for {
            sig := <-sigCh
            switch sig {
            case syscall.SIGHUP:
                handleSIGHUP()
            default:
                // Handle other signals as needed
            }
        }
    }()

    // ...
}

ljluestc avatar Sep 07 '23 07:09 ljluestc