Commit c8514ad7 authored by Matthew Holt's avatar Matthew Holt

Avoid panic if reloading before server is started

See: https://forum.caddyserver.com/t/reloading-template-files-as-they-change/1483/3?u=matt

The server takes a moment to start; if USR1 is received before the
instance is saved, it would panic because no instances have been saved.
Instead, we just ignore the signal since no config has finished loading.
parent 75ccc05d
......@@ -49,8 +49,14 @@ func trapSignalsPosix() {
// Start with the existing Caddyfile
instancesMu.Lock()
if len(instances) == 0 {
instancesMu.Unlock()
log.Println("[ERROR] SIGUSR1: No server instances are fully running")
continue
}
inst := instances[0] // we only support one instance at this time
instancesMu.Unlock()
updatedCaddyfile := inst.caddyfileInput
if updatedCaddyfile == nil {
// Hmm, did spawing process forget to close stdin? Anyhow, this is unusual.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment