diff options
author | 2016-08-19 17:14:17 -0700 | |
---|---|---|
committer | 2016-08-19 17:14:17 -0700 | |
commit | 9ac3cab1b7b1b1e78f86ce3c6a80fbee312162e6 (patch) | |
tree | 437e9755927c33af16276ad2602a6da115f948cb /core/sigtrap_posix.go | |
parent | a1989c35231b0e5ea271b2f68d82c1a63e697cd0 (diff) | |
download | coredns-9ac3cab1b7b1b1e78f86ce3c6a80fbee312162e6.tar.gz coredns-9ac3cab1b7b1b1e78f86ce3c6a80fbee312162e6.tar.zst coredns-9ac3cab1b7b1b1e78f86ce3c6a80fbee312162e6.zip |
Make CoreDNS a server type plugin for Caddy (#220)
* Make CoreDNS a server type plugin for Caddy
Remove code we don't need and port all middleware over. Fix all tests
and rework the documentation.
Also make `go generate` build a caddy binary which we then copy into
our directory. This means `go build`-builds remain working as-is.
And new etc instances in each etcd test for better isolation.
Fix more tests and rework test.Server with the newer support Caddy offers.
Fix Makefile to support new mode of operation.
Diffstat (limited to 'core/sigtrap_posix.go')
-rw-r--r-- | core/sigtrap_posix.go | 79 |
1 files changed, 0 insertions, 79 deletions
diff --git a/core/sigtrap_posix.go b/core/sigtrap_posix.go deleted file mode 100644 index d120dd52b..000000000 --- a/core/sigtrap_posix.go +++ /dev/null @@ -1,79 +0,0 @@ -// +build !windows - -package core - -import ( - "io/ioutil" - "log" - "os" - "os/signal" - "syscall" -) - -// trapSignalsPosix captures POSIX-only signals. -func trapSignalsPosix() { - go func() { - sigchan := make(chan os.Signal, 1) - signal.Notify(sigchan, syscall.SIGTERM, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGUSR1) - - for sig := range sigchan { - switch sig { - case syscall.SIGTERM: - log.Println("[INFO] SIGTERM: Terminating process") - if PidFile != "" { - os.Remove(PidFile) - } - os.Exit(0) - - case syscall.SIGQUIT: - log.Println("[INFO] SIGQUIT: Shutting down") - exitCode := executeShutdownCallbacks("SIGQUIT") - err := Stop() - if err != nil { - log.Printf("[ERROR] SIGQUIT stop: %v", err) - exitCode = 1 - } - if PidFile != "" { - os.Remove(PidFile) - } - os.Exit(exitCode) - - case syscall.SIGHUP: - log.Println("[INFO] SIGHUP: Hanging up") - err := Stop() - if err != nil { - log.Printf("[ERROR] SIGHUP stop: %v", err) - } - - case syscall.SIGUSR1: - log.Println("[INFO] SIGUSR1: Reloading") - - var updatedCorefile Input - - corefileMu.Lock() - if corefile == nil { - // Hmm, did spawing process forget to close stdin? Anyhow, this is unusual. - log.Println("[ERROR] SIGUSR1: no Corefile to reload (was stdin left open?)") - corefileMu.Unlock() - continue - } - if corefile.IsFile() { - body, err := ioutil.ReadFile(corefile.Path()) - if err == nil { - updatedCorefile = CorefileInput{ - Filepath: corefile.Path(), - Contents: body, - RealFile: true, - } - } - } - corefileMu.Unlock() - - err := Restart(updatedCorefile) - if err != nil { - log.Printf("[ERROR] SIGUSR1: %v", err) - } - } - } - }() -} |