cmd/syncthing: Introduce exiter to handle termination (#5532)

This commit is contained in:
Simon Frei
2019-02-14 00:07:27 +01:00
committed by Audrius Butkevicius
parent 905c3594b0
commit 7a40c42e8b
2 changed files with 36 additions and 24 deletions

View File

@@ -932,7 +932,7 @@ func (s *apiService) getSystemConfigInsync(w http.ResponseWriter, r *http.Reques
func (s *apiService) postSystemRestart(w http.ResponseWriter, r *http.Request) {
s.flushResponse(`{"ok": "restarting"}`, w)
go restart()
go exit.Restart()
}
func (s *apiService) postSystemReset(w http.ResponseWriter, r *http.Request) {
@@ -958,12 +958,12 @@ func (s *apiService) postSystemReset(w http.ResponseWriter, r *http.Request) {
s.flushResponse(`{"ok": "resetting folder `+folder+`"}`, w)
}
go restart()
go exit.Restart()
}
func (s *apiService) postSystemShutdown(w http.ResponseWriter, r *http.Request) {
s.flushResponse(`{"ok": "shutting down"}`, w)
go shutdown()
go exit.Shutdown()
}
func (s *apiService) flushResponse(resp string, w http.ResponseWriter) {
@@ -1383,8 +1383,7 @@ func (s *apiService) postSystemUpgrade(w http.ResponseWriter, r *http.Request) {
}
s.flushResponse(`{"ok": "restarting"}`, w)
l.Infoln("Upgrading")
stop <- exitUpgrading
exit.ExitUpgrading()
}
}