diff options
author | Matthew Holt <[email protected]> | 2020-05-12 11:36:20 -0600 |
---|---|---|
committer | Matthew Holt <[email protected]> | 2020-05-12 11:36:20 -0600 |
commit | aef560c7fc52092a412d9e97112b8cb879c5eda5 (patch) | |
tree | 905fce22478842dd8a8d07a65c8769e7db1c4cad /cmd | |
parent | 44536a7594f060dfca54a3cfb36135c93cba8e59 (diff) | |
download | caddy-aef560c7fc52092a412d9e97112b8cb879c5eda5.tar.gz caddy-aef560c7fc52092a412d9e97112b8cb879c5eda5.zip |
all: Recover from panics in goroutines
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/main.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/cmd/main.go b/cmd/main.go index fd82b969c..7e8d9b733 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -20,10 +20,12 @@ import ( "fmt" "io" "io/ioutil" + "log" "net" "os" "path/filepath" "runtime" + "runtime/debug" "strconv" "strings" "time" @@ -194,6 +196,12 @@ func loadConfig(configFile, adapterName string) ([]byte, string, error) { // long enough time. The filename passed in must be the actual // config file used, not one to be discovered. func watchConfigFile(filename, adapterName string) { + defer func() { + if err := recover(); err != nil { + log.Printf("[PANIC] watching config file: %v\n%s", err, debug.Stack()) + } + }() + // make our logger; since config reloads can change the // default logger, we need to get it dynamically each time logger := func() *zap.Logger { |