mirror of
https://github.com/akvorado/akvorado.git
synced 2025-12-11 22:14:02 +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
|
||||
}
|
||||
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)
|
||||
|
||||
@@ -4,13 +4,27 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"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() {
|
||||
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{
|
||||
@@ -18,7 +32,9 @@ var healthcheckCmd = &cobra.Command{
|
||||
Short: "Check healthness",
|
||||
Long: `Check if Akvorado is alive using the builtin HTTP endpoint.`,
|
||||
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 {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ identified with a specific icon:
|
||||
|
||||
- 🩹 *docker*: restart geoip container on boot
|
||||
- 🌱 *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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user