-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmain.go
More file actions
38 lines (31 loc) · 664 Bytes
/
main.go
File metadata and controls
38 lines (31 loc) · 664 Bytes
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
package main
import (
"flag"
"log"
"os"
"github.com/junhaideng/go-proxy/config"
"github.com/junhaideng/go-proxy/proxy"
)
var conf string
var logPath string
func init() {
flag.StringVar(&conf, "c", "config/config.yml", "config file path")
flag.StringVar(&logPath, "w", "", "write log to file")
}
func main() {
flag.Parse()
cfg, err := config.New(conf)
if err != nil {
panic(err)
}
if logPath != "" {
f, err := os.OpenFile(logPath, os.O_RDWR|os.O_APPEND|os.O_CREATE, 0666)
if err != nil {
panic(err)
}
log.SetOutput(f)
}
s := proxy.NewServer(cfg)
log.Printf("Start server on: %s:%d\n", cfg.Server.Host, cfg.Server.Port)
s.Run()
}