aboutsummaryrefslogtreecommitdiff
path: root/pkg/discord
diff options
context:
space:
mode:
authorMel <einebeere@gmail.com>2022-04-08 20:32:55 +0200
committerMel <einebeere@gmail.com>2022-04-08 20:32:55 +0200
commit81096040e0cf19ed1ff1ef25739ab11b99e0a7c9 (patch)
tree46fa4ca983be4ed38c2dd194e2a521f4023cd814 /pkg/discord
parent63a5c949f14c28ed29c2f2dc2490ff2542d249ef (diff)
downloadjinx-81096040e0cf19ed1ff1ef25739ab11b99e0a7c9.tar.zst
jinx-81096040e0cf19ed1ff1ef25739ab11b99e0a7c9.zip
Graceful closing
Diffstat (limited to 'pkg/discord')
-rw-r--r--pkg/discord/gateway/gateway.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/pkg/discord/gateway/gateway.go b/pkg/discord/gateway/gateway.go
index 6fe0087..9c86bb6 100644
--- a/pkg/discord/gateway/gateway.go
+++ b/pkg/discord/gateway/gateway.go
@@ -76,7 +76,14 @@ func (g *GatewayImpl) Start(ctx context.Context, url string, token string) error
}
func (g *GatewayImpl) Close() error {
- return g.conn.Close()
+ // Try closing gracefully.
+ g.logger.Debug().Msg("closing gateway gracefully...")
+ if err := g.conn.Close(1000); err != nil {
+ g.logger.Error().Err(err).Msg("error closing gateway gracefully, trying to murder...")
+ return g.conn.Kill()
+ }
+
+ return nil
}
func (g *GatewayImpl) Heartbeat() error {