fix: add timeout to server shutdown (#1116)

This commit is contained in:
Levi authored and GitHub committed 2025-09-13 21:19:28 +08:00
1 parent 7f08fa0b23
commit 04b0e691eb
1 file changed
+3 -1
+3 -1
View File
@@ -65,7 +65,9 @@ func Stop() {
}()
if srv != nil {
if err := srv.Shutdown(context.TODO()); err != nil {
shutdownCtx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
if err := srv.Shutdown(shutdownCtx); err != nil {
Downloader.Logger.Warn().Err(err).Msg("shutdown server failed")
}
}