Skip to content

Commit

Permalink
Restart haproxy
Browse files Browse the repository at this point in the history
  • Loading branch information
DAlperin committed Apr 4, 2023
1 parent 7475618 commit 06fcd85
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions pkg/commands/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 06fcd85

Please sign in to comment.