mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-23 03:18:59 +00:00
Write response before shutting down
This commit is contained in:
parent
30ea9cb37e
commit
1bf07d6b58
@ -157,19 +157,28 @@ func restGetConfigInSync(w http.ResponseWriter) {
|
||||
json.NewEncoder(w).Encode(map[string]bool{"configInSync": configInSync})
|
||||
}
|
||||
|
||||
func restPostRestart() {
|
||||
func restPostRestart(w http.ResponseWriter) {
|
||||
flushResponse(`{"ok": "restarting"}`, w)
|
||||
go restart()
|
||||
}
|
||||
|
||||
func restPostReset() {
|
||||
func restPostReset(w http.ResponseWriter) {
|
||||
flushResponse(`{"ok": "resetting repos"}`, w)
|
||||
resetRepositories()
|
||||
go restart()
|
||||
}
|
||||
|
||||
func restPostShutdown() {
|
||||
func restPostShutdown(w http.ResponseWriter) {
|
||||
flushResponse(`{"ok": "shutting down"}`, w)
|
||||
go shutdown()
|
||||
}
|
||||
|
||||
func flushResponse(s string, w http.ResponseWriter) {
|
||||
w.Write([]byte(s + "\n"))
|
||||
f := w.(http.Flusher)
|
||||
f.Flush()
|
||||
}
|
||||
|
||||
var cpuUsagePercent [10]float64 // The last ten seconds
|
||||
var cpuUsageLock sync.RWMutex
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user