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 is contained in:
2026-10-20 22:28:56 +00:00
committed by sneak
parent 497514d3df
commit bc1ab1a7f6
4 changed files with 176 additions and 31 deletions
+2
View File
@@ -325,6 +325,7 @@ func newTestServerFx(
cfg *config.Config,
mware *middleware.Middleware,
hdlr *handlers.Handlers,
shutdowner fx.Shutdowner,
) (*server.Server, error) {
srv, err := server.New(lifecycle, server.Params{ //nolint:exhaustruct
Logger: log,
@@ -332,6 +333,7 @@ func newTestServerFx(
Config: cfg,
Middleware: mware,
Handlers: hdlr,
Shutdowner: shutdowner,
})
if err != nil {
return nil, fmt.Errorf("test server: %w", err)