diff --git a/cmd/agent/agent.go b/cmd/agent/agent.go index 5f3d781e6..819aeb15b 100644 --- a/cmd/agent/agent.go +++ b/cmd/agent/agent.go @@ -17,6 +17,7 @@ package main import ( "context" "crypto/tls" + "fmt" "net/http" "os" "runtime" @@ -89,7 +90,7 @@ func loop(c *cli.Context) error { if c.Bool("healthcheck") { go func() { - if err := http.ListenAndServe(":3000", nil); err != nil { + if err := http.ListenAndServe(fmt.Sprintf(":%d", c.Int("healthcheck-port")), nil); err != nil { log.Error().Msgf("can not listen on port 3000: %v", err) } }() diff --git a/cmd/agent/flags.go b/cmd/agent/flags.go index ebf9b39c2..a613f8194 100644 --- a/cmd/agent/flags.go +++ b/cmd/agent/flags.go @@ -89,6 +89,12 @@ var flags = []cli.Flag{ Usage: "enable healthcheck endpoint", Value: true, }, + &cli.IntFlag{ + EnvVars: []string{"WOODPECKER_HEALTHCHECK_PORT"}, + Name: "healthcheck-port", + Usage: "port used for healthcheck endpoint", + Value: 3000, + }, &cli.DurationFlag{ EnvVars: []string{"WOODPECKER_KEEPALIVE_TIME"}, Name: "keepalive-time",