Skip to content

Commit

Permalink
chore: Return 502 from health endpoint on shutdown
Browse files Browse the repository at this point in the history
On shutdown, there will be a file at `/tmp/vroom.down`. When this file exists,
it's a sign that the pod will shutdown. So return 502 from the health endpoint.
  • Loading branch information
Zylphrex committed Sep 27, 2023
1 parent b248a9d commit 4b90ec9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cmd/vroom/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,11 @@ func main() {
}

func (e *environment) getHealth(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusNoContent)
if _, err := os.Stat("/tmp/vroom.down"); err == nil {
w.WriteHeader(http.StatusNoContent)
} else {
w.WriteHeader(http.StatusBadGateway)
}
}

type Filter struct {
Expand Down

0 comments on commit 4b90ec9

Please sign in to comment.