|
@@ -5,6 +5,10 @@ import (
|
|
"fmt"
|
|
"fmt"
|
|
"net/http"
|
|
"net/http"
|
|
_ "net/http/pprof"
|
|
_ "net/http/pprof"
|
|
|
|
+ "os"
|
|
|
|
+ "strings"
|
|
|
|
+
|
|
|
|
+ "github.com/zu1k/proxypool/config"
|
|
|
|
|
|
"github.com/zu1k/proxypool/internal/cron"
|
|
"github.com/zu1k/proxypool/internal/cron"
|
|
|
|
|
|
@@ -28,15 +32,17 @@ func main() {
|
|
go pprof()
|
|
go pprof()
|
|
}
|
|
}
|
|
|
|
|
|
- if configFilePath == "" {
|
|
|
|
- app.NeedFetchNewConfigFile = true
|
|
|
|
- app.FetchNewConfigFileThenInit()
|
|
|
|
|
|
+ envConfigFilePath := os.Getenv("CONFIG_FILE")
|
|
|
|
+ if envConfigFilePath == "" {
|
|
|
|
+ envConfigFilePath = "https://raw.githubusercontent.com/zu1k/proxypool/master/source.yaml"
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if configFilePath != "" {
|
|
|
|
+ initConfigFile(configFilePath)
|
|
} else {
|
|
} else {
|
|
- err := app.InitConfigAndGetters(configFilePath)
|
|
|
|
- if err != nil {
|
|
|
|
- fmt.Println(err)
|
|
|
|
- }
|
|
|
|
|
|
+ initConfigFile(envConfigFilePath)
|
|
}
|
|
}
|
|
|
|
+
|
|
proxy.InitGeoIpDB()
|
|
proxy.InitGeoIpDB()
|
|
|
|
|
|
go cron.Cron()
|
|
go cron.Cron()
|
|
@@ -45,6 +51,19 @@ func main() {
|
|
api.Run()
|
|
api.Run()
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+func initConfigFile(path string) {
|
|
|
|
+ if strings.HasPrefix(path, "http") {
|
|
|
|
+ config.Url = path
|
|
|
|
+ config.NeedFetch = true
|
|
|
|
+ app.FetchNewConfigFileThenInit()
|
|
|
|
+ } else {
|
|
|
|
+ err := app.InitConfigAndGetters(configFilePath)
|
|
|
|
+ if err != nil {
|
|
|
|
+ panic(err)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
func pprof() {
|
|
func pprof() {
|
|
ip := "127.0.0.1:6060"
|
|
ip := "127.0.0.1:6060"
|
|
if err := http.ListenAndServe(ip, nil); err != nil {
|
|
if err := http.ListenAndServe(ip, nil); err != nil {
|