forked from lanhebe/proxypool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
55 lines (48 loc) · 1.24 KB
/
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
55
package main
import (
"flag"
_ "net/http/pprof"
"os"
"github.com/lanhebe/proxypool/api"
"github.com/lanhebe/proxypool/internal/app"
"github.com/lanhebe/proxypool/internal/cron"
"github.com/lanhebe/proxypool/internal/database"
"github.com/lanhebe/proxypool/log"
"github.com/lanhebe/proxypool/pkg/proxy"
)
var configFilePath = ""
var debugMode = false
func main() {
//go func() {
// http.ListenAndServe("0.0.0.0:6060", nil)
//}()
flag.StringVar(&configFilePath, "c", "", "path to config file: config.yaml")
flag.BoolVar(&debugMode, "d", false, "debug output")
flag.Parse()
log.SetLevel(log.INFO)
if debugMode {
log.SetLevel(log.DEBUG)
}
if configFilePath == "" {
configFilePath = os.Getenv("CONFIG_FILE")
}
if configFilePath == "" {
configFilePath = "config.yaml"
}
err := app.InitConfigAndGetters(configFilePath)
if err != nil {
log.Errorln("Configuration init error: %s", err.Error())
panic(err)
}
database.InitTables()
// init GeoIp db reader and map between emoji's and countries
// return: struct geoIp (dbreader, emojimap)
err = proxy.InitGeoIpDB()
if err != nil {
os.Exit(1)
}
log.Infoln("Do the first crawl...")
go app.CrawlGo() // 抓取主程序
go cron.Cron() // 定时运行
api.Run() // Web Serve
}