Created
July 12, 2013 18:22
-
-
Save dustismo/5986631 to your computer and use it in GitHub Desktop.
How to have a clean exit from golang
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
killchan := make(chan os.Signal, 2) | |
signal.Notify(killchan, os.Interrupt, syscall.SIGTERM) | |
// wait for kill signal | |
<- killchan | |
log.Println("Kill sig!") | |
//do clean up | |
//now exit | |
os.Exit(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment