1
0
Fork 0

Split Web into API/Dashboard, ping, metric and Rest Provider

This commit is contained in:
SALLEYRON Julien 2017-11-09 16:12:04 +01:00 committed by Traefiker
parent 384488ac02
commit 27d1b46835
24 changed files with 1252 additions and 377 deletions

View file

@ -102,19 +102,25 @@ Complete documentation is available at https://traefik.io`,
healthCheckCmd := &flaeg.Command{
Name: "healthcheck",
Description: `Calls traefik /ping to check health (web provider must be enabled)`,
Description: `Calls traefik /ping to check health (ping must be enabled)`,
Config: traefikConfiguration,
DefaultPointersConfig: traefikPointersConfiguration,
Run: func() error {
traefikConfiguration.GlobalConfiguration.SetEffectiveConfiguration(traefikConfiguration.ConfigFile)
if traefikConfiguration.Web == nil {
fmt.Println("Please enable the web provider to use healtcheck.")
if traefikConfiguration.Ping == nil {
fmt.Println("Please enable `ping` to use healtcheck.")
os.Exit(1)
}
pingEntryPoint, ok := traefikConfiguration.EntryPoints[traefikConfiguration.Ping.EntryPoint]
if !ok {
pingEntryPoint = &configuration.EntryPoint{Address: ":8080"}
}
client := &http.Client{Timeout: 5 * time.Second}
protocol := "http"
if len(traefikConfiguration.Web.CertFile) > 0 {
if pingEntryPoint.TLS != nil {
protocol = "https"
tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
@ -122,9 +128,9 @@ Complete documentation is available at https://traefik.io`,
client.Transport = tr
}
resp, err := client.Head(protocol + "://" + traefikConfiguration.Web.Address + traefikConfiguration.Web.Path + "ping")
if err != nil {
fmt.Printf("Error calling healthcheck: %s\n", err)
resp, errPing := client.Head(protocol + "://" + pingEntryPoint.Address + traefikConfiguration.Web.Path + "ping")
if errPing != nil {
fmt.Printf("Error calling healthcheck: %s\n", errPing)
os.Exit(1)
}
if resp.StatusCode != http.StatusOK {