Skip to content

Commit d6b4a12

Browse files
chore: Create helper func to know if the monitoring port is configured (#4446)
Signed-off-by: Thomas Poignant <thomas.poignant@gofeatureflag.org>
1 parent dfa4855 commit d6b4a12

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

cmd/relayproxy/api/server.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func (s *Server) startUnixSocketServer(ctx context.Context) {
144144
}
145145

146146
// Start a http server for monitoring if monitoringport is configured
147-
if s.monitoringEcho != nil && s.config.GetMonitoringPort(s.zapLog) > 0 {
147+
if s.isMonitoringPortConfigured() {
148148
go s.startMonitoringServer()
149149
defer func() { _ = s.monitoringEcho.Close() }()
150150
}
@@ -176,7 +176,7 @@ func (s *Server) startUnixSocketServer(ctx context.Context) {
176176
// startAsHTTPServer launch the API server
177177
func (s *Server) startAsHTTPServer() {
178178
// starting the monitoring server on a different port if configured
179-
if s.monitoringEcho != nil {
179+
if s.isMonitoringPortConfigured() {
180180
go s.startMonitoringServer()
181181
defer func() { _ = s.monitoringEcho.Close() }()
182182
}
@@ -238,3 +238,8 @@ func (s *Server) Stop(ctx context.Context) {
238238
}
239239
}
240240
}
241+
242+
// isMonitoringPortConfigured checks if the monitoring port is configured.
243+
func (s *Server) isMonitoringPortConfigured() bool {
244+
return s.monitoringEcho != nil && s.config.GetMonitoringPort(s.zapLog) > 0
245+
}

0 commit comments

Comments
 (0)