Skip to content

Commit d08fd5b

Browse files
authored
fix: prevent HTTP and metrics ports from being the same (#482)
1 parent cde9d11 commit d08fd5b

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

cmd/doco-cd/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ func main() {
316316
log.Info("serving prometheus metrics", slog.Int("http_port", int(c.MetricsPort)), slog.String("path", prometheus.MetricsPath))
317317

318318
if err = prometheus.Serve(c.MetricsPort); err != nil {
319-
log.Error("failed to start Prometheus metrics server", logger.ErrAttr(err))
319+
log.Critical("failed to start Prometheus metrics server", logger.ErrAttr(err))
320320
} else {
321321
log.Debug("Prometheus metrics server started successfully", slog.Int("port", int(c.MetricsPort)))
322322
}

internal/config/app_config.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ func GetAppConfig() (*AppConfig, error) {
6767
return nil, err
6868
}
6969

70+
if cfg.HttpPort == cfg.MetricsPort {
71+
return nil, fmt.Errorf("HTTP_PORT and METRICS_PORT cannot be the same port number: %d", cfg.HttpPort)
72+
}
73+
7074
if cfg.HttpProxyString != "" {
7175
cfg.HttpProxy = transport.ProxyOptions{
7276
URL: cfg.HttpProxyString,

0 commit comments

Comments
 (0)