diff options
author | 2016-03-18 20:57:35 +0000 | |
---|---|---|
committer | 2016-03-18 20:57:35 +0000 | |
commit | 3ec0d9fe6b133a64712ae69fd712c14ad1a71f4d (patch) | |
tree | fae74c33cfed05de603785294593275f1901c861 /core/restart_windows.go | |
download | coredns-3ec0d9fe6b133a64712ae69fd712c14ad1a71f4d.tar.gz coredns-3ec0d9fe6b133a64712ae69fd712c14ad1a71f4d.tar.zst coredns-3ec0d9fe6b133a64712ae69fd712c14ad1a71f4d.zip |
First commit
Diffstat (limited to 'core/restart_windows.go')
-rw-r--r-- | core/restart_windows.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/core/restart_windows.go b/core/restart_windows.go new file mode 100644 index 000000000..c2a4f557a --- /dev/null +++ b/core/restart_windows.go @@ -0,0 +1,31 @@ +package core + +import "log" + +// Restart restarts Caddy forcefully using newCaddyfile, +// or, if nil, the current/existing Caddyfile is reused. +func Restart(newCaddyfile Input) error { + log.Println("[INFO] Restarting") + + if newCaddyfile == nil { + caddyfileMu.Lock() + newCaddyfile = caddyfile + caddyfileMu.Unlock() + } + + wg.Add(1) // barrier so Wait() doesn't unblock + + err := Stop() + if err != nil { + return err + } + + err = Start(newCaddyfile) + if err != nil { + return err + } + + wg.Done() // take down our barrier + + return nil +} |