Reload the config file on SIGHUP
This commit is contained in:
parent
9221a218b9
commit
04aef2f0e4
13
bot/bot.go
13
bot/bot.go
@ -77,6 +77,7 @@ func (b *Bot) RegisterHandlers() {
|
|||||||
|
|
||||||
func Run() error {
|
func Run() error {
|
||||||
initConfig()
|
initConfig()
|
||||||
|
go reloadConfig()
|
||||||
|
|
||||||
if err := lib.SeedMathRand(); err != nil {
|
if err := lib.SeedMathRand(); err != nil {
|
||||||
log.Warn(err)
|
log.Warn(err)
|
||||||
@ -150,5 +151,17 @@ func loadConfig() {
|
|||||||
|
|
||||||
if viper.GetBool("debug") {
|
if viper.GetBool("debug") {
|
||||||
log.SetLevel(log.DebugLevel)
|
log.SetLevel(log.DebugLevel)
|
||||||
|
} else {
|
||||||
|
log.SetLevel(log.InfoLevel)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func reloadConfig() {
|
||||||
|
sc := make(chan os.Signal, 1)
|
||||||
|
signal.Notify(sc, syscall.SIGHUP)
|
||||||
|
for {
|
||||||
|
<-sc
|
||||||
|
|
||||||
|
loadConfig()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user