diff --git a/pkg/commands/admin.go b/pkg/commands/admin.go index 0c850c0..90449dd 100644 --- a/pkg/commands/admin.go +++ b/pkg/commands/admin.go @@ -236,6 +236,21 @@ func handleEnableReadonly(w http.ResponseWriter, r *http.Request) { render.Err(w, err) } + args := []string{"root", "pkill", "haproxy"} + + cmd := exec.Command("gosu", args...) + + if err := cmd.Run(); err != nil { + render.Err(w, err) + return + } + + if cmd.ProcessState.ExitCode() != 0 { + err := fmt.Errorf(cmd.ProcessState.String()) + render.Err(w, err) + return + } + resp := &Response{Result: true} render.JSON(w, resp, http.StatusOK) @@ -254,6 +269,21 @@ func handleDisableReadonly(w http.ResponseWriter, r *http.Request) { render.Err(w, err) } + args := []string{"root", "pkill", "haproxy"} + + cmd := exec.Command("gosu", args...) + + if err := cmd.Run(); err != nil { + render.Err(w, err) + return + } + + if cmd.ProcessState.ExitCode() != 0 { + err := fmt.Errorf(cmd.ProcessState.String()) + render.Err(w, err) + return + } + resp := &Response{Result: true} render.JSON(w, resp, http.StatusOK)