From 05d9267f20a0008928dd873ac0285a8f84605ac8 Mon Sep 17 00:00:00 2001 From: Iwasaki Yudai Date: Tue, 1 Sep 2015 15:07:04 +0900 Subject: [PATCH] Show message for force exit --- app/app.go | 7 +++++-- main.go | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/app.go b/app/app.go index 06787aa..dd6488c 100644 --- a/app/app.go +++ b/app/app.go @@ -286,8 +286,11 @@ func (app *App) handleAuthToken(w http.ResponseWriter, r *http.Request) { func (app *App) Exit() (firstCall bool) { if app.server != nil { - log.Printf("Received Exit command, waiting for all clients to close sessions...") - return app.server.Close() + firstCall = app.server.Close() + if firstCall { + log.Printf("Received Exit command, waiting for all clients to close sessions...") + } + return firstCall } return true } diff --git a/main.go b/main.go index b7e2241..06cbaa4 100644 --- a/main.go +++ b/main.go @@ -120,7 +120,9 @@ func registerSignals(app *app.App) { s := <-sigChan switch s { case syscall.SIGINT, syscall.SIGTERM: - if !app.Exit() { + if app.Exit() { + fmt.Println("Send ^C to force exit.") + } else { os.Exit(5) } }