File tree Expand file tree Collapse file tree 1 file changed +16
-9
lines changed
Expand file tree Collapse file tree 1 file changed +16
-9
lines changed Original file line number Diff line number Diff line change @@ -295,17 +295,24 @@ func waitShutdown(cancel context.CancelFunc) {
295295 sigTimes := 0
296296 for {
297297 sig := <- quitCh
298- sigTimes ++
299- if sig != syscall .SIGINT {
300- log .Infof ("Got signal: %s." , sig )
301- } else {
302- log .Infof ("Got signal: %s to exit. Press Ctrl+C again to force exit." , sig )
303- if sigTimes >= 2 {
304- os .Exit (0 )
305- }
306- cancel ()
298+ if shouldForceExit := handleShutdownSignal (sig , & sigTimes , cancel ); shouldForceExit {
299+ os .Exit (0 )
307300 }
301+ }
302+ }
308303
304+ func handleShutdownSignal (sig os.Signal , sigTimes * int , cancel context.CancelFunc ) bool {
305+ if sig == syscall .SIGINT {
306+ * sigTimes = * sigTimes + 1
307+ log .Infof ("Got signal: %s to exit. Press Ctrl+C again to force exit." , sig )
308+ if * sigTimes >= 2 {
309+ return true
310+ }
311+ cancel ()
312+ return false
309313 }
310314
315+ log .Infof ("Got signal: %s to exit." , sig )
316+ cancel ()
317+ return false
311318}
You can’t perform that action at this time.
0 commit comments