Created
April 7, 2018 12:06
-
-
Save acoshift/c0c67e168becf6ddd57abbcf89a71a95 to your computer and use it in GitHub Desktop.
main.go for k8s app w/ hime
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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