<commit_before>package main

import (
	"flag"
	"fmt"
	"log"
	"net"
	"net/http"
	"os"
	"runtime"
	"runtime/debug"
	"strings"

	"github.com/eBay/fabio/consul"
	"github.com/eBay/fabio/metrics"
	"github.com/eBay/fabio/route"
	"github.com/eBay/fabio/ui"
)

var version = "1.0.1"

func main() {
	var cfg string
	var v bool
	flag.StringVar(&cfg, "cfg", "", "path to config file")
	flag.BoolVar(&v, "v", false, "show version")
	flag.Parse()

	if v {
		fmt.Println(version)
		return
	}

	log.Printf("[INFO] Version %s starting", version)

	if cfg != "" {
		if err := loadConfig(cfg); err != nil {
			log.Fatal("[FATAL] ", err)
		}
	}

	if err := metrics.Init(metricsTarget, metricsPrefix, metricsInterval, metricsGraphiteAddr); err != nil {
		log.Fatal("[FATAL] ", err)
	}

	if os.Getenv("GOMAXPROCS") == "" {
		log.Print("[INFO] Setting GOMAXPROCS=", gomaxprocs)
		runtime.GOMAXPROCS(gomaxprocs)
	} else {
		log.Print("[INFO] Using GOMAXPROCS=", os.Getenv("GOMAXPROCS"), " from env")
	}

	if os.Getenv("GOGC") == "" {
		log.Print("[INFO] Setting GOGC=", gogc)
		debug.SetGCPercent(gogc)
	} else {
		log.Print("[INFO] Using GOGC=", os.Getenv("GOGC"), " from env")
	}

	if proxyRoutes == "" {
		useDynamicRoutes()
	} else {
		useStaticRoutes()
	}

	if err := route.SetPickerStrategy(proxyStrategy); err != nil {
		log.Fatal("[FATAL] ", err)
	}

	dc, err := consul.Datacenter()
	if err != nil {
		log.Fatal("[FATAL] ", err)
	}

	log.Printf("[INFO] Using routing strategy %q", proxyStrategy)
	log.Printf("[INFO] Connecting to consul on %q in datacenter %q", consulAddr, dc)
	log.Printf("[INFO] Consul can be reached via %q", consulURL)

	log.Printf("[INFO] UI listening on %q", uiAddr)
	go func() {
		if err := ui.Start(uiAddr, consulKVPath); err != nil {
			log.Fatal("[FATAL] ui: ", err)<commit_msg>Honor consul.url and consul.addr from config file<commit_after>package main

import (
	"flag"
	"fmt"
	"log"
	"net"
	"net/http"
	"os"
	"runtime"
	"runtime/debug"
	"strings"

	"github.com/eBay/fabio/consul"
	"github.com/eBay/fabio/metrics"
	"github.com/eBay/fabio/route"
	"github.com/eBay/fabio/ui"
)

var version = "1.0.1"

func main() {
	var cfg string
	var v bool
	flag.StringVar(&cfg, "cfg", "", "path to config file")
	flag.BoolVar(&v, "v", false, "show version")
	flag.Parse()

	if v {
		fmt.Println(version)
		return
	}

	log.Printf("[INFO] Version %s starting", version)

	if cfg != "" {
		if err := loadConfig(cfg); err != nil {
			log.Fatal("[FATAL] ", err)
		}
	}

	if err := metrics.Init(metricsTarget, metricsPrefix, metricsInterval, metricsGraphiteAddr); err != nil {
		log.Fatal("[FATAL] ", err)
	}

	if os.Getenv("GOMAXPROCS") == "" {
		log.Print("[INFO] Setting GOMAXPROCS=", gomaxprocs)
		runtime.GOMAXPROCS(gomaxprocs)
	} else {
		log.Print("[INFO] Using GOMAXPROCS=", os.Getenv("GOMAXPROCS"), " from env")
	}

	if os.Getenv("GOGC") == "" {
		log.Print("[INFO] Setting GOGC=", gogc)
		debug.SetGCPercent(gogc)
	} else {
		log.Print("[INFO] Using GOGC=", os.Getenv("GOGC"), " from env")
	}

	if proxyRoutes == "" {
		useDynamicRoutes()
	} else {
		useStaticRoutes()
	}

	if err := route.SetPickerStrategy(proxyStrategy); err != nil {
		log.Fatal("[FATAL] ", err)
	}

	consul.Addr = consulAddr;
	consul.URL = consulURL;

	dc, err := consul.Datacenter()
	if err != nil {
		log.Fatal("[FATAL] ", err)
	}

	log.Printf("[INFO] Using routing strategy %q", proxyStrategy)
	log.Printf("[INFO] Connecting to consul on %q in datacenter %q", consulAddr, dc)
	log.Printf("[INFO] Consul can be reached via %q", consulURL)

	log.Printf("[INFO] UI listening on %q", uiAddr)
	go func() {
		if err := ui.Start(uiAddr, consulKVPath); err != nil {
			log.Fatal("[FATAL] ui: ", err)
{'fraction_non_alphanumeric': 0.18434687755658577, 'fraction_numerical': 0.001636214889555495, 'mean_word_length': 3.997275204359673, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6352973', 'n_tokens_mistral': 1532, 'n_tokens_neox': 1500, 'n_words': 323}