fix(xray): implement graceful shutdown for xray process and add tests (#4259)

This commit is contained in:
Farhad H. P. Shirvan
2026-05-11 14:11:40 +02:00
committed by GitHub
parent e642f7324e
commit 9318c2105f
4 changed files with 265 additions and 24 deletions
+4 -1
View File
@@ -12,6 +12,7 @@ import (
"os"
"strconv"
"strings"
"time"
"github.com/mhsanaei/3x-ui/v3/logger"
"github.com/mhsanaei/3x-ui/v3/util/common"
@@ -313,7 +314,9 @@ func (s *Server) Stop() error {
var err1 error
var err2 error
if s.httpServer != nil {
err1 = s.httpServer.Shutdown(s.ctx)
shutdownCtx, shutdownCancel := context.WithTimeout(context.Background(), 10*time.Second)
defer shutdownCancel()
err1 = s.httpServer.Shutdown(shutdownCtx)
}
if s.listener != nil {
err2 = s.listener.Close()