summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2020-05-12 11:36:20 -0600
committerMatthew Holt <mholt@users.noreply.github.com>2020-05-12 11:36:20 -0600
commitaef560c7fc52092a412d9e97112b8cb879c5eda5 (patch)
tree905fce22478842dd8a8d07a65c8769e7db1c4cad /cmd
parent44536a7594f060dfca54a3cfb36135c93cba8e59 (diff)
all: Recover from panics in goroutines
Diffstat (limited to 'cmd')
-rw-r--r--cmd/main.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/cmd/main.go b/cmd/main.go
index fd82b96..7e8d9b7 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 {