summaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorJakob Borg <jakob@nym.se>2014-05-12 21:15:18 -0300
committerJakob Borg <jakob@nym.se>2014-05-12 21:15:18 -0300
commit1bf07d6b588573d13471dfc0a41bc3cfcc4f79dd (patch)
tree291c510609c568852603b3574321f2e6d3016404 /cmd
parent30ea9cb37e27d61c4146a4381d9ac59c84b71109 (diff)
Write response before shutting down
Diffstat (limited to 'cmd')
-rw-r--r--cmd/syncthing/gui.go15
1 files changed, 12 insertions, 3 deletions
diff --git a/cmd/syncthing/gui.go b/cmd/syncthing/gui.go
index ac89d6f7dc..c5aa4b31cd 100644
--- a/cmd/syncthing/gui.go
+++ b/cmd/syncthing/gui.go
@@ -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