From d28080a9eb6d37700f29d49fcb61f6514f0749be Mon Sep 17 00:00:00 2001 From: qwerty287 <80460567+qwerty287@users.noreply.github.com> Date: Mon, 19 Sep 2022 00:07:37 +0200 Subject: [PATCH] Make healthcheck port configurable (#1197) Closes https://github.com/woodpecker-ci/woodpecker/issues/1193 Co-authored-by: 6543 <6543@obermui.de> --- cmd/agent/agent.go | 3 ++- cmd/agent/flags.go | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) 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",