Skip to content

Instantly share code, notes, and snippets.

@andelf
Created June 29, 2013 05:25
Show Gist options
  • Star 31 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save andelf/5889946 to your computer and use it in GitHub Desktop.
Save andelf/5889946 to your computer and use it in GitHub Desktop.
golang process SIGHUP, HUP signal to reload configuration
// program
package main
import "os/signal"
import "os"
import "fmt"
import "syscall"
import "time"
func main() {
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGHUP)
go func(){
for sig := range c {
println(sig)
fmt.Printf("Got A HUP Signal! Now Reloading Conf....\n")
}
}()
for {
time.Sleep(1000 * time.Millisecond)
fmt.Printf(">>")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment