From 656d092ad652bd296d436229c332da58a5543c3c Mon Sep 17 00:00:00 2001 From: Eugene Bujak Date: Sun, 7 Oct 2018 00:59:21 +0300 Subject: [PATCH] if coredns unexpectedly quits, restart it --- control.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/control.go b/control.go index cc902f3a..06adb498 100644 --- a/control.go +++ b/control.go @@ -142,9 +142,14 @@ func handleStart(w http.ResponseWriter, r *http.Request) { func childwaiter() { err := coreDNSCommand.Wait() - log.Printf("coredns terminated: %s\n", err) - err = coreDNSCommand.Process.Release() - log.Printf("coredns released: %s\n", err) + log.Printf("coredns unexpectedly died: %s\n", err) + coreDNSCommand.Process.Release() + log.Printf("restarting coredns\n", err) + err = startDNSServer() + if err != nil { + log.Printf("Couldn't restart DNS server: %s\n", err) + return + } } func handleStop(w http.ResponseWriter, r *http.Request) {