main.go 827 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package main
  2. import (
  3. "flag"
  4. "fmt"
  5. "net/http"
  6. _ "net/http/pprof"
  7. "os"
  8. "github.com/zu1k/proxypool/api"
  9. "github.com/zu1k/proxypool/internal/app"
  10. "github.com/zu1k/proxypool/internal/cron"
  11. "github.com/zu1k/proxypool/internal/database"
  12. "github.com/zu1k/proxypool/pkg/proxy"
  13. )
  14. var configFilePath = ""
  15. func main() {
  16. go func() {
  17. http.ListenAndServe("0.0.0.0:6060", nil)
  18. }()
  19. flag.StringVar(&configFilePath, "c", "", "path to config file: config.yaml")
  20. flag.Parse()
  21. if configFilePath == "" {
  22. configFilePath = os.Getenv("CONFIG_FILE")
  23. }
  24. if configFilePath == "" {
  25. configFilePath = "config.yaml"
  26. }
  27. err := app.InitConfigAndGetters(configFilePath)
  28. if err != nil {
  29. panic(err)
  30. }
  31. database.InitTables()
  32. proxy.InitGeoIpDB()
  33. fmt.Println("Do the first crawl...")
  34. go app.CrawlGo()
  35. go cron.Cron()
  36. api.Run()
  37. }