<commit_before>package main

import (
	"flag"
	log "github.com/Sirupsen/logrus"
	_ "github.com/mattn/go-sqlite3"
	"math/rand"
	"net/http"
	"os"
	"path"
	"time"
)

const coreOSAppID = "{e96281a6-d1af-4bde-9a0a-97b76e56dc57}"

var db *userDB
var fileBE fileBackend
var myHostname string // local hostname advertised in responses

func main() {
	var err error
	flag.StringVar(&myHostname, "hostname", "", "hostname advertised when using local file backend")
	flag.Parse()
	if myHostname == "" {
		log.Error("You must set the 'hostname' parameter when using local file backend.")
		os.Exit(1)
	}

	log.SetLevel(log.DebugLevel)
	log.Info("COmaha update server starting")

	// seed the RNG
	rand.Seed(time.Now().UnixNano())

	// open db
	db, err = newUserDB("users.sqlite")
	if err != nil {
		log.Errorf("Could not open database: %v", err.Error())
		os.Exit(1)
	}
	defer db.Close()

	cwd, err := os.Getwd()
	if err != nil {
		log.Errorf("Could not cwd: %v", err.Error())
	}
	lfbe := newLocalFileBackend(path.Join(cwd, "storage"))
	fileBE = &lfbe

	http.HandleFunc("/file", fileHandler)
	http.HandleFunc("/update", updateHandler)
	http.HandleFunc("/shutdown", shutdownHandler)
	//http.HandleFunc("/admin/add_group", addGroupHandler)
	http.HandleFunc("/admin/add_payload", addPayloadHandler)
	//http.HandleFunc("/admin/add_user", addUserHandler)
	http.HandleFunc("/", homeHandler)
	http.ListenAndServe(":8080", nil)
}<commit_msg>allow to specify listening address<commit_after>package main

import (
	"flag"
	"fmt"
	log "github.com/Sirupsen/logrus"
	_ "github.com/mattn/go-sqlite3"
	"math/rand"
	"net/http"
	"os"
	"path"
	"time"
)

const coreOSAppID = "{e96281a6-d1af-4bde-9a0a-97b76e56dc57}"

var db *userDB
var fileBE fileBackend
var myHostname string // local hostname advertised in responses
var listenAddr string // address to listen on

func main() {
	var err error
	flag.StringVar(&myHostname, "hostname", "", "hostname advertised when using local file backend")
	flag.StringVar(&listenAddr, "listenaddr", "0.0.0.0", "address to listen on")
	flag.Parse()
	if myHostname == "" {
		log.Error("You must set the 'hostname' parameter when using local file backend.")
		os.Exit(1)
	}

	log.SetLevel(log.DebugLevel)
	log.Info("COmaha update server starting")

	// seed the RNG
	rand.Seed(time.Now().UnixNano())

	// open db
	db, err = newUserDB("users.sqlite")
	if err != nil {
		log.Errorf("Could not open database: %v", err.Error())
		os.Exit(1)
	}
	defer db.Close()

	cwd, err := os.Getwd()
	if err != nil {
		log.Errorf("Could not cwd: %v", err.Error())
	}
	lfbe := newLocalFileBackend(path.Join(cwd, "storage"))
	fileBE = &lfbe

	http.HandleFunc("/file", fileHandler)
	http.HandleFunc("/update", updateHandler)
	http.HandleFunc("/shutdown", shutdownHandler)
	//http.HandleFunc("/admin/add_group", addGroupHandler)
	http.HandleFunc("/admin/add_payload", addPayloadHandler)
	//http.HandleFunc("/admin/add_user", addUserHandler)
	http.HandleFunc("/", homeHandler)

	listenString := fmt.Sprintf("%v:8080", listenAddr)
	http.ListenAndServe(listenString, nil)
}
{'fraction_non_alphanumeric': 0.15629095674967233, 'fraction_numerical': 0.017693315858453473, 'mean_word_length': 4.612132352941177, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, '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': '1702321', 'n_tokens_mistral': 1160, 'n_tokens_neox': 1115, 'n_words': 254}