mirror of
https://github.com/caddyserver/caddy.git
synced 2025-01-06 22:40:31 -05:00
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.
This commit is contained in:
parent
75ccc05d84
commit
c8514ad7b7
1 changed files with 6 additions and 0 deletions
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue