Run starts the application, blocks on the signals channel, and then gracefully shuts the application down. It uses [DefaultTimeout] to set a deadline for application startup and shutdown, unless the user has configured different timeouts with the [StartTimeout] or [StopTimeout] options. It's designe
()
| 594 | // if startup or shutdown operations fail, |
| 595 | // or if the [Shutdowner] supplied a non-zero exit code. |
| 596 | func (app *App) Run() { |
| 597 | // Historically, we do not os.Exit(0) even though most applications |
| 598 | // cede control to Fx with they call app.Run. To avoid a breaking |
| 599 | // change, never os.Exit for success. |
| 600 | if code := app.run(app.Wait); code != 0 { |
| 601 | app.exit(code) |
| 602 | } |
| 603 | } |
| 604 | |
| 605 | func (app *App) run(done func() <-chan ShutdownSignal) (exitCode int) { |
| 606 | startCtx, cancel := app.clock.WithTimeout(context.Background(), app.StartTimeout()) |