Revert 11711 adding url param to healthcheck command

This commit is contained in:
Landry Benguigui 2025-07-22 17:10:05 +02:00 committed by GitHub
parent 78cc85283c
commit 028e8ca0b0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 29 deletions

View File

@ -2,7 +2,6 @@ package healthcheck
import ( import (
"errors" "errors"
"flag"
"fmt" "fmt"
"net/http" "net/http"
"os" "os"
@ -23,26 +22,11 @@ func NewCmd(traefikConfiguration *static.Configuration, loaders []cli.ResourceLo
} }
} }
func runCmd(traefikConfiguration *static.Configuration) func(args []string) error { func runCmd(traefikConfiguration *static.Configuration) func(_ []string) error {
return func(args []string) error { return func(_ []string) error {
fs := flag.NewFlagSet("healthcheck", flag.ContinueOnError)
urlFlag := fs.String("url", "", "")
fs.SetOutput(os.Stderr)
if err := fs.Parse(args); err != nil {
return err
}
traefikConfiguration.SetEffectiveConfiguration() traefikConfiguration.SetEffectiveConfiguration()
var resp *http.Response resp, errPing := Do(*traefikConfiguration)
var errPing error
if *urlFlag != "" {
client := &http.Client{Timeout: 5 * time.Second}
resp, errPing = client.Head(*urlFlag)
} else {
resp, errPing = Do(*traefikConfiguration)
}
if resp != nil { if resp != nil {
resp.Body.Close() resp.Body.Close()
} }

View File

@ -27,16 +27,6 @@ $ traefik healthcheck
OK: http://:8082/ping OK: http://:8082/ping
``` ```
### URL Option
The URL to check can be specified with the `--url` flag, which defaults to `http://localhost:8080/ping`.
Example:
```sh
traefik healthcheck --url=http://localhost:8080/ping
```
## Ping ## Ping
The `/ping` health-check URL is enabled with the command-line `--ping` or config file option `[ping]`. The `/ping` health-check URL is enabled with the command-line `--ping` or config file option `[ping]`.