Skip to content

Instantly share code, notes, and snippets.

@acoshift
Created April 7, 2018 12:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acoshift/c0c67e168becf6ddd57abbcf89a71a95 to your computer and use it in GitHub Desktop.
Save acoshift/c0c67e168becf6ddd57abbcf89a71a95 to your computer and use it in GitHub Desktop.
main.go for k8s app w/ hime
package main
import (
"log"
"net/http"
"time"
"github.com/acoshift/hime"
"github.com/acoshift/probehandler"
)
func main() {
probe := probehandler.New()
health := http.NewServeMux()
health.Handle("/readiness", probe)
health.Handle("/liveness", probehandler.Success())
err := hime.New().
Handler(hime.Factory(http.DefaultServeMux)).
GracefulShutdown().
Notify(probe.Fail).
Wait(5 * time.Second).
Timeout(10 * time.Second).
Before(func() { go http.ListenAndServe(":18080", health) }).
ListenAndServe(":8080")
if err != nil {
log.Fatal(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment