<commit_before>package main

import (
	"flag"
	"log"
	"net/http"
	"runtime"
)

var pubAddr = flag.String("pubAddr", ":8080", "Address on which to serve public requests")
var apiAddr = flag.String("apiAddr", ":8081", "Address on which to receive reload requests")
var mongoUrl = flag.String("mongoUrl", "localhost", "Address of mongo cluster (e.g. 'mongo1,mongo2,mongo3')")
var mongoDbName = flag.String("mongoDbName", "router", "Name of mongo database to use")

var quit = make(chan int)

func main() {
	// Use all available cores
	runtime.GOMAXPROCS(runtime.NumCPU())

	flag.Parse()

	rout := NewRouter(*mongoUrl, *mongoDbName)
	rout.ReloadRoutes()

	go http.ListenAndServe(*pubAddr, rout)
	log.Println("router: listening for requests on " + *pubAddr)

	// This applies to DefaultServeMux, below.
	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		if r.Method != "POST" {
			http.NotFound(w, r)
			return
		}

		rout.ReloadRoutes()
	})
	go http.ListenAndServe(*apiAddr, nil)
	log.Println("router: listening for refresh on " + *apiAddr)

	<-quit
}<commit_msg>[#58693908] Bail if unable to bind TCP ports<commit_after>package main

import (
	"flag"
	"log"
	"net/http"
	"runtime"
)

var pubAddr = flag.String("pubAddr", ":8080", "Address on which to serve public requests")
var apiAddr = flag.String("apiAddr", ":8081", "Address on which to receive reload requests")
var mongoUrl = flag.String("mongoUrl", "localhost", "Address of mongo cluster (e.g. 'mongo1,mongo2,mongo3')")
var mongoDbName = flag.String("mongoDbName", "router", "Name of mongo database to use")

var quit = make(chan int)

func main() {
	// Use all available cores
	runtime.GOMAXPROCS(runtime.NumCPU())

	flag.Parse()

	rout := NewRouter(*mongoUrl, *mongoDbName)
	rout.ReloadRoutes()

	go func() {
		err := http.ListenAndServe(*pubAddr, rout)
		if err != nil {
			log.Fatal(err)
		}
	}()
	log.Println("router: listening for requests on " + *pubAddr)

	// This applies to DefaultServeMux, below.
	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		if r.Method != "POST" {
			http.NotFound(w, r)
			return
		}

		rout.ReloadRoutes()
	})
	go func() {
		err := http.ListenAndServe(*apiAddr, nil)
		if err != nil {
			log.Fatal(err)
		}
	}()
	log.Println("router: listening for refresh on " + *apiAddr)

	<-quit
}
{'fraction_non_alphanumeric': 0.15334773218142547, 'fraction_numerical': 0.012958963282937365, 'mean_word_length': 4.386046511627907, 'pattern_counts': {'":': 4, '<': 5, '<?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': '3148254', 'n_tokens_mistral': 893, 'n_tokens_neox': 826, 'n_words': 221}