fix: improve HTTP server startup with better error detection

- Added better error detection for HTTP server startup
- Added connectivity check to verify server is actually listening
- Increased wait time to 500ms for better error detection
- Added warning log if server connectivity check fails (may still be starting)
- Improved logging messages for server startup

This should help diagnose why the HTTP server isn't starting and provide better visibility into the startup process.
This commit is contained in:
2025-11-05 19:42:13 +01:00
parent d1d0b170ce
commit 512d76a6fb
2 changed files with 56 additions and 7 deletions

View File

@@ -123,9 +123,23 @@ func registerRoutes(
// Start starts the HTTP server.
func (s *Server) Start() error {
// ListenAndServe will block until the server is closed
// If there's an immediate error (like port in use), it will return immediately
return s.httpServer.ListenAndServe()
}
// StartAsync starts the HTTP server in a goroutine and returns a channel that signals when it's ready or errored.
func (s *Server) StartAsync() <-chan error {
errChan := make(chan error, 1)
go func() {
if err := s.Start(); err != nil && err != http.ErrServerClosed {
errChan <- err
}
close(errChan)
}()
return errChan
}
// Shutdown gracefully shuts down the HTTP server.
func (s *Server) Shutdown(ctx context.Context) error {
return s.httpServer.Shutdown(ctx)