MCPcopy
hub / github.com/perkeep/perkeep / serveRestart

Method serveRestart

pkg/server/status.go:300–332  ·  view source on GitHub ↗
(rw http.ResponseWriter, req *http.Request)

Source from the content-addressed store, hash-verified

298}
299
300func (sh *StatusHandler) serveRestart(rw http.ResponseWriter, req *http.Request) {
301 if req.Method != "POST" {
302 http.Error(rw, "POST to restart", http.StatusMethodNotAllowed)
303 return
304 }
305
306 _, handlers := sh.handlerFinder.AllHandlers()
307 for _, h := range handlers {
308 ah, ok := h.(*app.Handler)
309 if !ok {
310 continue
311 }
312 log.Printf("Sending SIGINT to %s", ah.ProgramName())
313 err := ah.Quit()
314 if err != nil {
315 msg := fmt.Sprintf("Not restarting: couldn't interrupt app %s: %v", ah.ProgramName(), err)
316 log.Print(msg)
317 http.Error(rw, msg, http.StatusInternalServerError)
318 return
319 }
320 }
321
322 reindex := (req.FormValue("reindex") == "on")
323 recovery, _ := strconv.Atoi(req.FormValue("recovery"))
324
325 log.Println("Restarting perkeepd")
326 rw.Header().Set("Connection", "close")
327 http.Redirect(rw, req, sh.prefix, http.StatusFound)
328 if f, ok := rw.(http.Flusher); ok {
329 f.Flush()
330 }
331 osutil.RestartProcess(fmt.Sprintf("-reindex=%t", reindex), fmt.Sprintf("-recovery=%d", recovery))
332}
333
334var cgoEnabled bool

Callers 1

ServeHTTPMethod · 0.95

Calls 9

RestartProcessFunction · 0.92
PrintfMethod · 0.80
ProgramNameMethod · 0.80
QuitMethod · 0.80
PrintlnMethod · 0.80
AllHandlersMethod · 0.65
SetMethod · 0.65
ErrorMethod · 0.45
FlushMethod · 0.45

Tested by

no test coverage detected