feat: add dependency shutdown and configurable service endpoints
This commit is contained in:
@@ -41,12 +41,17 @@ func run(ctx context.Context, path string) (runErr error) {
|
||||
}
|
||||
// RunContext drains HTTP requests before returning. This scope owns dependencies
|
||||
// and closes them exactly once, before closing the borrowed logger.
|
||||
defer func() { runErr = errors.Join(runErr, deps.Close()) }()
|
||||
defer func() {
|
||||
runErr = errors.Join(runErr, deps.Close())
|
||||
if cause := deps.Lifecycle.Err(); cause != nil && !errors.Is(runErr, cause) {
|
||||
runErr = errors.Join(runErr, cause)
|
||||
}
|
||||
}()
|
||||
app, err := handler.NewApp(deps)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() { runErr = errors.Join(runErr, app.Close()) }()
|
||||
logger.InfoContext(ctx, "service.starting", "address", app.Config().Address)
|
||||
return app.RunContext(ctx)
|
||||
return app.RunContext(deps.Lifecycle.Context())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user