12345678910111213141516171819202122232425 |
- // Copyright 2019 getensh.com. All rights reserved.
- // Use of this source code is governed by getensh.com.
- package utils
- import (
- "os"
- "os/signal"
- "syscall"
- "time"
- )
- var ExitRecieved bool
- func HandleExitSignal() {
- sigs := make(chan os.Signal, 1)
- signal.Notify(sigs, syscall.SIGTERM)
- go func() {
- <-sigs
- ExitRecieved = true
- t := time.NewTimer(5 * time.Second)
- <-t.C
- os.Exit(0)
- }()
- }
|