-
Notifications
You must be signed in to change notification settings - Fork 35
/
main.go
54 lines (41 loc) · 853 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package main
import (
"flag"
"os"
"os/signal"
"syscall"
"github.com/polevpn/anyvalue"
"github.com/polevpn/elog"
)
const (
CH_TUNIO_WRITE_SIZE = 4096
)
var Config *anyvalue.AnyValue
var configPath string
func init() {
flag.StringVar(&configPath, "config", "./config.json", "config file path")
}
func signalHandler() {
c := make(chan os.Signal)
signal.Notify(c, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
go func() {
for s := range c {
switch s {
case syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT:
elog.Fatal("receive exit signal,exit")
default:
}
}
}()
}
func main() {
flag.Parse()
defer elog.Flush()
signalHandler()
var err error
Config, err = GetConfig(configPath)
if err != nil {
elog.Fatal("load config fail", err)
}
NewPoleVPNRouter().Start(Config)
}