This commit is contained in:
Random Guy 2026-06-24 20:26:20 +03:30 committed by GitHub
commit e248e8a43d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -91,7 +91,6 @@ func executeRun(cmd *base.Command, args []string) {
fmt.Println("Failed to start:", err)
os.Exit(-1)
}
defer server.Close()
// Explicitly triggering GC to remove garbage from config loading.
runtime.GC()
@ -102,6 +101,22 @@ func executeRun(cmd *base.Command, args []string) {
signal.Notify(osSignals, os.Interrupt, syscall.SIGTERM)
<-osSignals
}
closeDone := make(chan error, 1)
go func() {
closeDone <- server.Close()
}()
select {
case err := <-closeDone:
if err != nil {
fmt.Println("Failed to close:", err)
os.Exit(1)
}
case <-time.After(10 * time.Second):
fmt.Println("Timed out while closing Xray.")
os.Exit(1)
}
}
func dumpConfig() int {