Skip to content

Instantly share code, notes, and snippets.

@ibnesayeed
Forked from andelf/sighup.go
Created June 3, 2016 15:18
Show Gist options
  • Save ibnesayeed/37ea43ef9b3fe4ecac63e92749c6e804 to your computer and use it in GitHub Desktop.
Save ibnesayeed/37ea43ef9b3fe4ecac63e92749c6e804 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