Created
February 13, 2018 04:40
-
-
Save syossan27/4b495db5b60f592eb9e47a4f44ad2ba8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sigc := make(chan os.Signal, 1) | |
signal.Notify(sigc, os.Interrupt, syscall.SIGTERM) | |
go func(ln net.Listener, c chan os.Signal) { | |
sig := <-c | |
log.Printf("Caught signal %s: shutting down.", sig) | |
ln.Close() | |
os.Exit(0) | |
}(ln, sigc) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment