mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-23 22:27:38 -05:00
7d5b6b96ea
Go programs using the caddy package may not want the it to capture all the signals...
27 lines
481 B
Go
27 lines
481 B
Go
package caddy
|
|
|
|
// Restart restarts Caddy forcefully using newCaddyfile,
|
|
// or, if nil, the current/existing Caddyfile is reused.
|
|
func Restart(newCaddyfile Input) error {
|
|
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
|
|
}
|