Skip to content

Commit

Permalink
Add /up health check
Browse files Browse the repository at this point in the history
  • Loading branch information
mat committed Nov 3, 2024
1 parent 934829e commit c64b8f4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions besticon/iconserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ func startServer(port string, address string) {
registerHandler("/icon", s.iconHandler)
registerHandler("/allicons.json", s.alliconsHandler)
registerHandler("/lettericons/", s.lettericonHandler)
registerHandler("/up", s.upHandler)

disableBrowsePages := getTrueFromEnv("DISABLE_BROWSE_PAGES")

Expand Down Expand Up @@ -420,6 +421,12 @@ func registerHandler(path string, f http.HandlerFunc) {
http.Handle(path, newPrometheusHandler(path, f))
}

// /up is a simple health check endpoint (used by kamal deploy)
func (s *server) upHandler(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
w.Write([]byte("OK"))
}

func main() {
fmt.Printf("iconserver %s (%s) (%s) - https://github.com/mat/besticon\n", besticon.VersionString, besticon.BuildDate, runtime.Version())
port := os.Getenv("PORT")
Expand Down

0 comments on commit c64b8f4

Please sign in to comment.