Browse Source

Shutdown from GUI (ref #192)

Jakob Borg 11 years ago
parent
commit
20b23338f7
2 changed files with 11 additions and 2 deletions
  1. 7 2
      cmd/syncthing/gui.go
  2. 4 0
      cmd/syncthing/main.go

+ 7 - 2
cmd/syncthing/gui.go

@@ -53,6 +53,7 @@ func startGUI(cfg GUIConfiguration, m *Model) error {
 	router.Post("/rest/config", restPostConfig)
 	router.Post("/rest/restart", restPostRestart)
 	router.Post("/rest/reset", restPostReset)
+	router.Post("/rest/shutdown", restPostShutdown)
 	router.Post("/rest/error", restPostError)
 	router.Post("/rest/error/clear", restClearErrors)
 
@@ -156,15 +157,19 @@ func restGetConfigInSync(w http.ResponseWriter) {
 	json.NewEncoder(w).Encode(map[string]bool{"configInSync": configInSync})
 }
 
-func restPostRestart(req *http.Request) {
+func restPostRestart() {
 	go restart()
 }
 
-func restPostReset(req *http.Request) {
+func restPostReset() {
 	resetRepositories()
 	go restart()
 }
 
+func restPostShutdown() {
+	go shutdown()
+}
+
 var cpuUsagePercent [10]float64 // The last ten seconds
 var cpuUsageLock sync.RWMutex
 

+ 4 - 0
cmd/syncthing/main.go

@@ -431,6 +431,10 @@ func restart() {
 	stop <- true
 }
 
+func shutdown() {
+	stop <- true
+}
+
 var saveConfigCh = make(chan struct{})
 
 func saveConfigLoop(cfgFile string) {