forked from zu1k/proxypool
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathmain.go
50 lines (42 loc) · 876 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
package main
import (
"flag"
"fmt"
"net/http"
_ "net/http/pprof"
_ "github.com/mkevac/debugcharts"
"github.com/zu1k/proxypool/api"
"github.com/zu1k/proxypool/app"
"github.com/zu1k/proxypool/proxy"
)
var (
debugMode = false
configFilePath = ""
)
func main() {
flag.StringVar(&configFilePath, "c", "", "path to config file: source.yaml")
flag.BoolVar(&debugMode, "d", false, "debug mode")
flag.Parse()
if debugMode {
go pprof()
}
if configFilePath == "" {
app.NeedFetchNewConfigFile = true
} else {
err := app.InitConfigAndGetters(configFilePath)
if err != nil {
fmt.Println(err)
}
}
proxy.InitGeoIpDB()
go app.Cron()
fmt.Println("Do the first crawl...")
go app.CrawlGo()
api.Run()
}
func pprof() {
ip := "127.0.0.1:6060"
if err := http.ListenAndServe(ip, nil); err != nil {
fmt.Printf("start pprof failed on %s\n", ip)
}
}