diff --git a/pkg/osutil/restart_unix.go b/pkg/osutil/restart_unix.go index 84d5a5cb7..a1c0805c3 100644 --- a/pkg/osutil/restart_unix.go +++ b/pkg/osutil/restart_unix.go @@ -56,13 +56,25 @@ func SelfPath() (string, error) { return "", errors.New("SelfPath not implemented for " + runtime.GOOS) } -// RestartProcess returns an error if things couldn't be -// restarted. On success, this function never returns -// because the process becomes the new process. -func RestartProcess() error { +// RestartProcess restarts the process with the given arguments, if any, +// replacing the original process's arguments. It defaults to os.Args otherwise. It +// returns an error if things couldn't be restarted. On success, this function +// never returns because the process becomes the new process. +func RestartProcess(arg ...string) error { path, err := SelfPath() if err != nil { return fmt.Errorf("RestartProcess failed: %v", err) } - return syscall.Exec(path, os.Args, os.Environ()) + + var args []string + if len(arg) > 0 { + args = append(args, os.Args[0]) + for _, v := range arg { + args = append(args, v) + } + } else { + args = os.Args + } + + return syscall.Exec(path, args, os.Environ()) } diff --git a/pkg/server/status.go b/pkg/server/status.go index 2f6465e46..ec743c89f 100644 --- a/pkg/server/status.go +++ b/pkg/server/status.go @@ -243,7 +243,8 @@ func (sh *StatusHandler) serveStatusHTML(rw http.ResponseWriter, req *http.Reque f("") f("

Admin

") - f("
") + f("
") + f(" reindex
") f("

Handlers

") f("

As JSON: status.json; and the discovery JSON.

", st.rootPrefix) @@ -285,13 +286,15 @@ func (sh *StatusHandler) serveRestart(rw http.ResponseWriter, req *http.Request) } } + reindex := (req.FormValue("reindex") == "on") + log.Println("Restarting camlistored") rw.Header().Set("Connection", "close") http.Redirect(rw, req, sh.prefix, http.StatusFound) if f, ok := rw.(http.Flusher); ok { f.Flush() } - osutil.RestartProcess() + osutil.RestartProcess(fmt.Sprintf("-reindex=%t", reindex)) } var cgoEnabled bool