Add health-check endpoint

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2022-11-20 00:53:34 +01:00
parent 3982c9c381
commit 1d55196bdf
Signed by: luzifer
GPG key ID: D91C3E91E4CAD6F5
2 changed files with 2 additions and 0 deletions

View file

@ -55,6 +55,7 @@ In all cases specify one or more `--vehicle-id` (`VEHICLE_ID=WDB111111ZZZ22222,W
When everything is running you should be able to access the exporter: When everything is running you should be able to access the exporter:
- `https://exporter.example.com/auth` - Redirect to authorize your project to access your car(s) - `https://exporter.example.com/auth` - Redirect to authorize your project to access your car(s)
- `https://exporter.example.com/healthz` - Health-Check endpoint
- `https://exporter.example.com/metrics` - Text-version of exported metrics - `https://exporter.example.com/metrics` - Text-version of exported metrics
You need to access the `/auth` route once to fetch access- and refresh-keys. If something wents wrong with those keys you can re-authorize the app using this route. You need to access the `/auth` route once to fetch access- and refresh-keys. If something wents wrong with those keys you can re-authorize the app using this route.

View file

@ -76,6 +76,7 @@ func main() {
// Register HTTP handlers // Register HTTP handlers
http.DefaultServeMux.HandleFunc("/auth", getAuthRedirectHandler(mClient)) http.DefaultServeMux.HandleFunc("/auth", getAuthRedirectHandler(mClient))
http.DefaultServeMux.HandleFunc("/store-token", getAuthStoreTokenHandler(mClient, creds)) http.DefaultServeMux.HandleFunc("/store-token", getAuthStoreTokenHandler(mClient, creds))
http.DefaultServeMux.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) { w.Write([]byte("OK")) })
http.DefaultServeMux.Handle("/metrics", promhttp.Handler()) http.DefaultServeMux.Handle("/metrics", promhttp.Handler())
scheduler := cron.New() scheduler := cron.New()