-
-
Save phuocglh/d88b50cf45a8933bdf541d4529fc9ea3 to your computer and use it in GitHub Desktop.
golang process SIGHUP, HUP signal to reload configuration
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
| // 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