mirror of
https://github.com/octoleo/syncthing.git
synced 2025-02-08 23:08:27 +00:00
Merge branch 'pr/683'
* pr/683: Restart monitor as part of the upgrade process (fixes #682)
This commit is contained in:
commit
517b7a14b4
@ -531,7 +531,9 @@ func restPostUpgrade(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
restPostRestart(w, r)
|
flushResponse(`{"ok": "restarting"}`, w)
|
||||||
|
l.Infoln("Upgrading")
|
||||||
|
stop <- exitUpgrading
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,6 +56,7 @@ const (
|
|||||||
exitError = 1
|
exitError = 1
|
||||||
exitNoUpgradeAvailable = 2
|
exitNoUpgradeAvailable = 2
|
||||||
exitRestarting = 3
|
exitRestarting = 3
|
||||||
|
exitUpgrading = 4
|
||||||
)
|
)
|
||||||
|
|
||||||
var l = logger.DefaultLogger
|
var l = logger.DefaultLogger
|
||||||
|
@ -91,6 +91,18 @@ func monitorMain() {
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
// Successfull exit indicates an intentional shutdown
|
// Successfull exit indicates an intentional shutdown
|
||||||
return
|
return
|
||||||
|
} else if exiterr, ok := err.(*exec.ExitError); ok {
|
||||||
|
if status, ok := exiterr.Sys().(syscall.WaitStatus); ok {
|
||||||
|
switch status.ExitStatus() {
|
||||||
|
case exitUpgrading:
|
||||||
|
// Restart the monitor process to release the .old
|
||||||
|
// binary as part of the upgrade process.
|
||||||
|
l.Infoln("Restarting monitor...")
|
||||||
|
os.Setenv("STNORESTART", "")
|
||||||
|
exec.Command(args[0], args[1:]...).Start()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user