Closed ThinkChaos closed 3 years ago
Thanks for sending this!
What do you think of just adding this endpoint to the monitoring server?
The monitoring server is quite sensitive since it can contain private information in the logs and dumps, so it's important not to expose it already, and clear in documentation, defaults, etc.
My suggestion is to add something like this to monitoring.go:
// In launchMonitoringServer:
// http.HandleFunc("/quit", quitHandler)
func quitHandler(w http.ResponseWriter, r *http.Request) {
if r.Method != "POST" {
http.Error(w, "Use POST method for quitting", http.StatusMethodNotAllowed)
return
}
log.Info("Received /quit")
os.Exit(0)
}
What do you think?
This looks great!
Sorry I won't be able to merge this right now, but I'll post another update once it's been added, hopefully tomorrow :)
Thanks again!
Merged to the next
branch in commit 99ec58bfcd, with two amends: I added some tests, and I also adjusted the shutdown to happen after srv.Shutdown call completes, instead of server return, as per the Server.Shutdown docs.
If you have any further suggestions, please let me know! I'm happy to amend or split these changes if you prefer.
I will keep this change in next
for a bit and once it has gotten enough exposure I'll move it to master
, for inclusion in the next release.
Thanks a lot again!
Allows terminating chasquid via the network. Useful to trigger a restart (if there is an init system to relaunch chasquid) and thus reload certificates.
Fixes #12