mirror of
https://github.com/sorenisanerd/gotty.git
synced 2024-11-22 12:24:25 +00:00
Show message for force exit
This commit is contained in:
parent
ff92777011
commit
05d9267f20
@ -286,8 +286,11 @@ func (app *App) handleAuthToken(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
func (app *App) Exit() (firstCall bool) {
|
func (app *App) Exit() (firstCall bool) {
|
||||||
if app.server != nil {
|
if app.server != nil {
|
||||||
log.Printf("Received Exit command, waiting for all clients to close sessions...")
|
firstCall = app.server.Close()
|
||||||
return app.server.Close()
|
if firstCall {
|
||||||
|
log.Printf("Received Exit command, waiting for all clients to close sessions...")
|
||||||
|
}
|
||||||
|
return firstCall
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
4
main.go
4
main.go
@ -120,7 +120,9 @@ func registerSignals(app *app.App) {
|
|||||||
s := <-sigChan
|
s := <-sigChan
|
||||||
switch s {
|
switch s {
|
||||||
case syscall.SIGINT, syscall.SIGTERM:
|
case syscall.SIGINT, syscall.SIGTERM:
|
||||||
if !app.Exit() {
|
if app.Exit() {
|
||||||
|
fmt.Println("Send ^C to force exit.")
|
||||||
|
} else {
|
||||||
os.Exit(5)
|
os.Exit(5)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user