diff options
| author | wuyuxiang <wuyuxiang@corp.netease.com> | 2020-04-28 14:10:23 +0800 |
|---|---|---|
| committer | wuyuxiang <wuyuxiang@corp.netease.com> | 2020-04-28 14:10:23 +0800 |
| commit | 6850d28d6b99155dca2da8fa8bbf76124f528fa4 (patch) | |
| tree | 2a6eb0dd50a530dfb72496a69715438c9aa15a44 /weed/util/signal_handling.go | |
| parent | 2a7957b4ca83fdb5232d761074e81dce6b99648f (diff) | |
| download | seaweedfs-6850d28d6b99155dca2da8fa8bbf76124f528fa4.tar.xz seaweedfs-6850d28d6b99155dca2da8fa8bbf76124f528fa4.zip | |
refacotr: move signal handling and pprof to grace package
Diffstat (limited to 'weed/util/signal_handling.go')
| -rw-r--r-- | weed/util/signal_handling.go | 46 |
1 files changed, 0 insertions, 46 deletions
diff --git a/weed/util/signal_handling.go b/weed/util/signal_handling.go deleted file mode 100644 index 99447e8be..000000000 --- a/weed/util/signal_handling.go +++ /dev/null @@ -1,46 +0,0 @@ -// +build !plan9 - -package util - -import ( - "os" - "os/signal" - "sync" - "syscall" -) - -var signalChan chan os.Signal -var hooks = make([]func(), 0) -var hookLock sync.Mutex - -func init() { - signalChan = make(chan os.Signal, 1) - signal.Ignore(syscall.SIGHUP) - signal.Notify(signalChan, - os.Interrupt, - os.Kill, - syscall.SIGALRM, - // syscall.SIGHUP, - syscall.SIGINT, - syscall.SIGTERM, - // syscall.SIGQUIT, - ) - go func() { - for _ = range signalChan { - for _, hook := range hooks { - hook() - } - os.Exit(0) - } - }() -} - -func OnInterrupt(fn func()) { - // prevent reentry - hookLock.Lock() - defer hookLock.Unlock() - - // deal with control+c,etc - // controlling terminal close, daemon not exit - hooks = append(hooks, fn) -} |
