From d4036006b2e85e308e9a19c58af500e336ae2cf5 Mon Sep 17 00:00:00 2001 From: bert0RM Date: Thu, 26 Dec 2024 15:20:20 -0800 Subject: [PATCH] add host ports as config flags --- pkg/query-service/app/server.go | 10 ++++++---- pkg/query-service/main.go | 16 ++++++++++++++-- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/pkg/query-service/app/server.go b/pkg/query-service/app/server.go index 20d183876c..1ff2ecb657 100644 --- a/pkg/query-service/app/server.go +++ b/pkg/query-service/app/server.go @@ -56,6 +56,8 @@ type ServerOptions struct { SkipTopLvlOpsPath string HTTPHostPort string PrivateHostPort string + DebugHostPort string + OpAmpWsEndpoint string // alert specific params DisableRules bool RuleRepoURL string @@ -656,9 +658,9 @@ func (s *Server) Start() error { }() go func() { - zap.L().Info("Starting pprof server", zap.String("addr", constants.DebugHttpPort)) + zap.L().Info("Starting pprof server", zap.String("addr", s.serverOptions.DebugHostPort)) - err = http.ListenAndServe(constants.DebugHttpPort, nil) + err = http.ListenAndServe(s.serverOptions.DebugHostPort, nil) if err != nil { zap.L().Error("Could not start pprof server", zap.Error(err)) } @@ -685,8 +687,8 @@ func (s *Server) Start() error { }() go func() { - zap.L().Info("Starting OpAmp Websocket server", zap.String("addr", constants.OpAmpWsEndpoint)) - err := s.opampServer.Start(constants.OpAmpWsEndpoint) + zap.L().Info("Starting OpAmp Websocket server", zap.String("addr", s.serverOptions.OpAmpWsEndpoint)) + err := s.opampServer.Start(s.serverOptions.OpAmpWsEndpoint) if err != nil { zap.L().Info("opamp ws server failed to start", zap.Error(err)) s.unavailableChannel <- healthcheck.Unavailable diff --git a/pkg/query-service/main.go b/pkg/query-service/main.go index 1f1c54b961..efe48a3b10 100644 --- a/pkg/query-service/main.go +++ b/pkg/query-service/main.go @@ -50,6 +50,11 @@ func main() { var maxOpenConns int var dialTimeout time.Duration + var httpHostPort string + var privateHostPort string + var debugHostPort string + var opAmpWsEndpoint string + flag.BoolVar(&useLogsNewSchema, "use-logs-new-schema", false, "use logs_v2 schema for logs") flag.BoolVar(&useTraceNewSchema, "use-trace-new-schema", false, "use new schema for traces") flag.StringVar(&promConfigPath, "config", "./config/prometheus.yml", "(prometheus config to read metrics)") @@ -65,6 +70,11 @@ func main() { flag.IntVar(&maxIdleConns, "max-idle-conns", 50, "(number of connections to maintain in the pool, only used with clickhouse if not set in ClickHouseUrl env var DSN.)") flag.IntVar(&maxOpenConns, "max-open-conns", 100, "(max connections for use at any time, only used with clickhouse if not set in ClickHouseUrl env var DSN.)") flag.DurationVar(&dialTimeout, "dial-timeout", 5*time.Second, "(the maximum time to establish a connection, only used with clickhouse if not set in ClickHouseUrl env var DSN.)") + // Host ports + flag.StringVar(&httpHostPort, "http-host-port", constants.HTTPHostPort, "Address to listen on for HTTP requests") + flag.StringVar(&privateHostPort, "private-host-port", constants.PrivateHostPort, "Address to listen on for private HTTP requests") + flag.StringVar(&debugHostPort, "debug-host-port", constants.DebugHttpPort, "Address to listen on for debug HTTP requests") + flag.StringVar(&opAmpWsEndpoint, "opamp-ws-endpoint", constants.OpAmpWsEndpoint, "Address to listen on for OpAmp WS requests") flag.Parse() loggerMgr := initZapLog() @@ -75,11 +85,13 @@ func main() { version.PrintVersion() serverOptions := &app.ServerOptions{ - HTTPHostPort: constants.HTTPHostPort, + HTTPHostPort: httpHostPort, + PrivateHostPort: privateHostPort, + DebugHostPort: debugHostPort, + OpAmpWsEndpoint: opAmpWsEndpoint, PromConfigPath: promConfigPath, SkipTopLvlOpsPath: skipTopLvlOpsPath, PreferSpanMetrics: preferSpanMetrics, - PrivateHostPort: constants.PrivateHostPort, DisableRules: disableRules, RuleRepoURL: ruleRepoURL, MaxIdleConns: maxIdleConns,