1
0
mirror of https://github.com/stryan/mumble-discord-bridge.git synced 2024-11-16 20:15:40 -05:00

recover from panic on shutdown

This commit is contained in:
Tyler Stiene 2021-04-24 13:17:11 -04:00
parent a1f6a60b89
commit 235dc44f41

11
main.go
View File

@ -197,9 +197,16 @@ func main() {
Bridge.Mode = bridgeModeConstant
Bridge.DiscordChannelID = Bridge.BridgeConfig.CID
go func() {
defer func() {
if r := recover(); r != nil {
fmt.Println("Bridge paniced", r)
}
}()
for {
Bridge.startBridge()
log.Println("Bridge died. Restarting")
log.Println("Bridge died")
time.Sleep(5 * time.Second)
log.Println("Restarting")
}
}()
default:
@ -211,7 +218,7 @@ func main() {
// Shutdown on OS signal
sc := make(chan os.Signal, 1)
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill)
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt)
<-sc
log.Println("OS Signal. Bot shutting down")