<commit_before>package main

import (
	"flag"
	"fmt"
	"github.com/op/go-logging"
	"net/http"
	"os/signal"
	"syscall"
	"os"
	"fox"
	"util"
)

var log = logging.MustGetLogger("FoxService")


func main()  {
	
	var port = flag.Int("port", 8090, "Port to bind to on the localhost interface")
	var slog = flag.Bool("syslog", false, "If present, logs are sent to syslog")
	flag.Parse()

	initConfig()
	setupLogging(slog)
	
	router := fox.NewRouter()
	log.Infof("Starting a server on localhost:%d", *port)
	log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", *port), router))
}

func initConfig()  {
	util.LoadConfig()
	
	sc := make(chan os.Signal, 1)
	
	signal.Notify(sc, syscall.SIGHUP)
	
	go func ()  {
		for {
			<-sc
			util.LoadConfig()
		}		
	}()
}

func setupLogging(slog *bool)  {
	var b logging.Backend
	
	format := logging.MustStringFormatter(
    	`%{color}%{time:15:04:05.000} %{shortfunc} ▶ %{level:.4s} %{id:03x}%{color:reset} %{message}`,
	)

	if *slog  {
		b, _ = logging.NewSyslogBackend("Fox")	
	}else{
		b = logging.NewLogBackend(os.Stdout, "", 0)	
	}
	
	bFormatter := logging.NewBackendFormatter(b, format)
	logging.SetBackend(bFormatter)	
}<commit_msg>Fixed the foxservice crash upon token submit<commit_after>package main

import (
	"flag"
	"fmt"
	"github.com/op/go-logging"
	"net/http"
	"os/signal"
	"syscall"
	"os"
	"fox"
	"util"
	"authn"
)

var log = logging.MustGetLogger("FoxService")


func main()  {
	
	var port = flag.Int("port", 8090, "Port to bind to on the localhost interface")
	var slog = flag.Bool("syslog", false, "If present, logs are sent to syslog")
	flag.Parse()

	initConfig()
	setupLogging(slog)
	
	router := fox.NewRouter()
	log.Infof("Starting a server on localhost:%d", *port)
	log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", *port), router))
}

func initConfig()  {
	util.LoadConfig()
	authn.InitValidator()
	
	sc := make(chan os.Signal, 1)
	
	signal.Notify(sc, syscall.SIGHUP)
	
	go func ()  {
		for {
			<-sc
			util.LoadConfig()
		}		
	}()
}

func setupLogging(slog *bool)  {
	var b logging.Backend
	
	format := logging.MustStringFormatter(
    	`%{color}%{time:15:04:05.000} %{shortfunc} ▶ %{level:.4s} %{id:03x}%{color:reset} %{message}`,
	)

	if *slog  {
		b, _ = logging.NewSyslogBackend("Fox")	
	}else{
		b = logging.NewLogBackend(os.Stdout, "", 0)	
	}
	
	bFormatter := logging.NewBackendFormatter(b, format)
	logging.SetBackend(bFormatter)	
}
{'fraction_non_alphanumeric': 0.17120133947258268, 'fraction_numerical': 0.01506906655504395, 'mean_word_length': 4.042194092827004, 'pattern_counts': {'":': 2, '<': 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': '2954619', 'n_tokens_mistral': 1037, 'n_tokens_neox': 932, 'n_words': 196}