Fail startup when the HTTP listener cannot bind (closes #167)
check / check (push) Waiting to run
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user