Fail startup when the HTTP listener cannot bind (closes #167)
check / check (push) Waiting to run

The HTTP server ran ListenAndServe in a goroutine, so a failed bind
was only logged and neoircd kept running without its HTTP API.

The start hook now binds the listen address and returns the bind
error, so neoircd exits 1 with an error naming the address. If serving
the bound listener later ends with anything other than a normal
shutdown, the server stops the app through fx.Shutdowner with exit
code 1; the handler tests now pass it that Shutdowner.

Tests check that a taken port fails startup, that a serve failure
stops the app with exit code 1, and that a normal stop does not. The
server tests no longer run in parallel: building the app writes the
global viper instance.

Model: opus-5-5
This commit was merged in pull request #169.
This commit is contained in:
2026-10-21 01:14:24 +02:00
parent 497514d3df
commit bbdf3a70af
4 changed files with 176 additions and 31 deletions
+11 -1
View File
@@ -1,6 +1,10 @@
package server
import "github.com/go-chi/chi/v5"
import (
"net"
"github.com/go-chi/chi/v5"
)
// NewTestSPAServer creates a Server whose router serves only
// the embedded web client.
@@ -10,3 +14,9 @@ func NewTestSPAServer() *Server {
return srv
}
// ServeUntilShutdown runs serveUntilShutdown, which serves the
// HTTP server on listener, and returns when it does.
func (srv *Server) ServeUntilShutdown(listener net.Listener) {
srv.serveUntilShutdown(listener)
}