mirror of
https://github.com/akvorado/akvorado.git
synced 2025-12-12 06:24:10 +01:00
cmd/healthcheck: add --host and --port flags
But really, this could be autodiscovered through an abstract Unix socket instead.
This commit is contained in:
8
.github/e2e.sh
vendored
8
.github/e2e.sh
vendored
@@ -102,6 +102,14 @@ EOF
|
|||||||
nix run nixpkgs#hurl -- --test --error-format=long .github/e2e.hurl
|
nix run nixpkgs#hurl -- --test --error-format=long .github/e2e.hurl
|
||||||
}
|
}
|
||||||
echo ::endgroup::
|
echo ::endgroup::
|
||||||
|
|
||||||
|
# Docker Compose
|
||||||
|
echo ::group::Docker healthcheck test
|
||||||
|
docker compose ps --format json \
|
||||||
|
| jq 'map(select(.State != "running" or .Health == "unhealthy")) | map({Service, State, Status, Health})'
|
||||||
|
docker compose ps --format json \
|
||||||
|
| jq -e 'map(select(.State != "running" or .Health == "unhealthy")) | length == 0'
|
||||||
|
echo ::endgroup::
|
||||||
;;
|
;;
|
||||||
|
|
||||||
coverage)
|
coverage)
|
||||||
|
|||||||
@@ -4,13 +4,27 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type healthcheckOptions struct {
|
||||||
|
Host string
|
||||||
|
Port uint16
|
||||||
|
}
|
||||||
|
|
||||||
|
// HealthcheckOptions stores the command-line option values for the healthcheck
|
||||||
|
// command.
|
||||||
|
var HealthcheckOptions healthcheckOptions
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
RootCmd.AddCommand(healthcheckCmd)
|
RootCmd.AddCommand(healthcheckCmd)
|
||||||
|
healthcheckCmd.Flags().Uint16VarP(&HealthcheckOptions.Port, "port", "p", 8080,
|
||||||
|
"HTTP port for health check")
|
||||||
|
healthcheckCmd.Flags().StringVarP(&HealthcheckOptions.Host, "host", "h", "localhost",
|
||||||
|
"HTTP host for health check")
|
||||||
}
|
}
|
||||||
|
|
||||||
var healthcheckCmd = &cobra.Command{
|
var healthcheckCmd = &cobra.Command{
|
||||||
@@ -18,7 +32,9 @@ var healthcheckCmd = &cobra.Command{
|
|||||||
Short: "Check healthness",
|
Short: "Check healthness",
|
||||||
Long: `Check if Akvorado is alive using the builtin HTTP endpoint.`,
|
Long: `Check if Akvorado is alive using the builtin HTTP endpoint.`,
|
||||||
RunE: func(cmd *cobra.Command, _ []string) error {
|
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||||
resp, err := http.Get("http://localhost:8080/api/v0/healthcheck")
|
resp, err := http.Get(fmt.Sprintf("http://%s:%d/api/v0/healthcheck",
|
||||||
|
HealthcheckOptions.Host,
|
||||||
|
HealthcheckOptions.Port))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ identified with a specific icon:
|
|||||||
|
|
||||||
- 🩹 *docker*: restart geoip container on boot
|
- 🩹 *docker*: restart geoip container on boot
|
||||||
- 🌱 *orchestrator*: add `kafka`→`manage-topic` flag to enable or disable topic management
|
- 🌱 *orchestrator*: add `kafka`→`manage-topic` flag to enable or disable topic management
|
||||||
|
- 🌱 *cmd*: add `--host` and `--port` flags to `akvorado healthcheck`
|
||||||
|
|
||||||
## 2.0.3 - 2025-11-19
|
## 2.0.3 - 2025-11-19
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user