From 7eebf3c30827569be4e0f5c3914ad2be5e1d9bbf Mon Sep 17 00:00:00 2001 From: Abhinav Gupta Date: Sat, 4 Jan 2025 08:56:11 -0800 Subject: [PATCH] doc(App.Run): Clarify exit code (#1254) A user expressed confusion about the exit code of an Fx application that was interrupted with Ctrl-C. Clarify in the documentation that the exit code will be non-zero only if there was a failure, or if Shutdown specifically requested a non-zero exit code. --- app.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app.go b/app.go index ef3d35a0d..7a0168fc0 100644 --- a/app.go +++ b/app.go @@ -595,6 +595,14 @@ func (app *App) exit(code int) { // All of Run's functionality is implemented in terms of the exported // Start, Done, and Stop methods. Applications with more specialized needs // can use those methods directly instead of relying on Run. +// +// After the application has started, +// it can be shut down by sending a signal or calling [Shutdowner.Shutdown]. +// On successful shutdown, whether initiated by a signal or by the user, +// Run will return to the caller, allowing it to exit cleanly. +// Run will exit with a non-zero status code +// if startup or shutdown operations fail, +// or if the [Shutdowner] supplied a non-zero exit code. func (app *App) Run() { // Historically, we do not os.Exit(0) even though most applications // cede control to Fx with they call app.Run. To avoid a breaking