From 229cf08cc94a1fb026a3382b2046bf1bbf2ee520 Mon Sep 17 00:00:00 2001 From: HuKeping Date: Fri, 20 May 2016 04:52:12 +0800 Subject: [PATCH] [PATCH 6/8] Feature: hot configuration reload for notary server This patch will allow people to use SIGHUP to tell notary server to reload the configuration file. For now it only supports to reload the logging level. Signed-off-by: Hu Keping --- cmd/notary-server/config.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmd/notary-server/config.go b/cmd/notary-server/config.go index 2845ec5204..cf1cf8804c 100644 --- a/cmd/notary-server/config.go +++ b/cmd/notary-server/config.go @@ -309,6 +309,14 @@ func reloadConfig(sig os.Signal, configFile string, oldConfig *viper.Viper, envP fmt.Println("Decrease log level failed, will use the old one, error: ", err) return } + case syscall.SIGHUP: + // We use SIGHUP to allow people to reset the logging level as their wish. + lvl, err := utils.ParseLogLevel(config, logrus.ErrorLevel) + if err != nil { + fmt.Println("Parse log level failed, will use the old one, error: ", err) + return + } + logrus.SetLevel(lvl) } fmt.Println("Successfully setting log level to ", logrus.GetLevel())