瀏覽代碼

respond to system signals

v2ray 9 年之前
父節點
當前提交
61ce85435f
共有 1 個文件被更改,包括 6 次插入5 次删除
  1. 6 5
      release/server/main.go

+ 6 - 5
release/server/main.go

@@ -4,9 +4,8 @@ import (
 	"flag"
 	"fmt"
 	"os"
+	"os/signal"
 	"path/filepath"
-	"runtime"
-	"time"
 
 	"github.com/v2ray/v2ray-core"
 	_ "github.com/v2ray/v2ray-core/app/router/rules"
@@ -94,7 +93,9 @@ func main() {
 		return
 	}
 
-	for range time.Tick(time.Minute) {
-		runtime.GC()
-	}
+	osSignals := make(chan os.Signal, 1)
+	signal.Notify(osSignals, os.Interrupt, os.Kill)
+
+	<-osSignals
+	vPoint.Close()
 }