mirror of
https://github.com/wahyd4/forego.git
synced 2026-08-09 05:07:05 +10:00
catch more signals instead of just sigint
This commit is contained in:
committed by
David Dollar
parent
dd6e9899ca
commit
7d31007cd6
@@ -9,6 +9,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -100,15 +101,16 @@ type Forego struct {
|
||||
|
||||
func (f *Forego) monitorInterrupt() {
|
||||
handler := make(chan os.Signal, 1)
|
||||
signal.Notify(handler, os.Interrupt)
|
||||
signal.Notify(handler, syscall.SIGALRM, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM)
|
||||
|
||||
first := true
|
||||
|
||||
for sig := range handler {
|
||||
switch sig {
|
||||
case os.Interrupt:
|
||||
case syscall.SIGINT:
|
||||
fmt.Println(" | ctrl-c detected")
|
||||
|
||||
fallthrough
|
||||
default:
|
||||
f.teardown.Fall()
|
||||
if !first {
|
||||
f.teardownNow.Fall()
|
||||
|
||||
Reference in New Issue
Block a user