mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-06-28 04:03:07 +00:00
Merge 09e5e23c24 into dda2b10c9d
This commit is contained in:
commit
e248e8a43d
1 changed files with 16 additions and 1 deletions
17
main/run.go
17
main/run.go
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue