mirror of
https://github.com/stryan/mumble-discord-bridge.git
synced 2024-12-27 17:05:40 -05:00
recover from panic on shutdown
This commit is contained in:
parent
a1f6a60b89
commit
235dc44f41
11
main.go
11
main.go
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user