mirror of
https://github.com/stryan/mumble-discord-bridge.git
synced 2024-12-28 01:15:38 -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.Mode = bridgeModeConstant
|
||||||
Bridge.DiscordChannelID = Bridge.BridgeConfig.CID
|
Bridge.DiscordChannelID = Bridge.BridgeConfig.CID
|
||||||
go func() {
|
go func() {
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
fmt.Println("Bridge paniced", r)
|
||||||
|
}
|
||||||
|
}()
|
||||||
for {
|
for {
|
||||||
Bridge.startBridge()
|
Bridge.startBridge()
|
||||||
log.Println("Bridge died. Restarting")
|
log.Println("Bridge died")
|
||||||
|
time.Sleep(5 * time.Second)
|
||||||
|
log.Println("Restarting")
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
default:
|
default:
|
||||||
@ -211,7 +218,7 @@ func main() {
|
|||||||
|
|
||||||
// Shutdown on OS signal
|
// Shutdown on OS signal
|
||||||
sc := make(chan os.Signal, 1)
|
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
|
<-sc
|
||||||
|
|
||||||
log.Println("OS Signal. Bot shutting down")
|
log.Println("OS Signal. Bot shutting down")
|
||||||
|
Loading…
Reference in New Issue
Block a user