<commit_before>package main

import (
	"flag"
	"fmt"
	"log"
	"net/http"
	"time"

	"github.com/sebest/hooky/restapi"
	"github.com/sebest/hooky/scheduler"
	"github.com/sebest/hooky/store"
	"github.com/stretchr/graceful"
)

var (
	bind             = flag.String("bind", ":8000", "address to bind on")
	mongoURI         = flag.String("mongo-uri", "localhost/hooky", "MongoDB URI to connect to")
	adminPassword    = flag.String("admin-password", "<PASSWORD>", "<PASSWORD> password")
	maxMongoQuerier  = flag.Int("max-mongo-query", 1, "maximum number of parallel queries on MongoDB")
	maxHTTPRequester = flag.Int("max-http-request", 20, "maximum number of parallel HTTP requests")
	touchInterval    = flag.Int("touch-interval", 5, "frequency to update the tasks reservation duration in seconds")
)

func main() {
	flag.Parse()

	s, err := store.New(*mongoURI)
	if err != nil {
		log.Fatal(err)
	}
	sched := scheduler.New(s, *maxMongoQuerier, *maxHTTPRequester, *touchInterval)
	sched.Start()
	ra, err := restapi.New(s, *adminPassword)
	if err != nil {
		log.Fatal(err)
	}

	server := &graceful.Server{
		Timeout: 10 * time.Second,
		Server: &http.Server{
			Addr:    *bind,
			Handler: ra.MakeHandler(),
		},
	}

	server.ListenAndServe()
	fmt.Println("exiting")
	sched.Stop()
	fmt.Println("exited")
}
<commit_msg>Use codegangsta CLI<commit_after>package main

import (
	"fmt"
	"log"
	"net/http"
	"os"
	"time"

	"github.com/codegangsta/cli"
	"github.com/sebest/hooky/restapi"
	"github.com/sebest/hooky/scheduler"
	"github.com/sebest/hooky/store"
	"github.com/stretchr/graceful"
)

func main() {
	app := cli.NewApp()
	app.Name = "hooky"
	app.Usage = "the webhooks scheduler"
	app.Version = "0.1"
	app.Author = "<NAME>"
	app.Email = "<EMAIL>"
	app.Flags = []cli.Flag{
		cli.StringFlag{
			Name:   "bind",
			Value:  ":8000",
			Usage:  "address to bind on",
			EnvVar: "HOOKY_BIND",
		},
		cli.StringFlag{
			Name:   "mongo-uri",
			Value:  "localhost/hooky",
			Usage:  "MongoDB URI to connect to",
			EnvVar: "HOOKY_MONGO_URI",
		},
		cli.StringFlag{
			Name:   "admin-password",
			Value:  "<PASSWORD>",
			Usage:  "admin password",
			EnvVar: "HOOKY_ADMIN_PASSWORD",
		},
		cli.IntFlag{
			Name:   "max-mongo-query",
			Value:  1,
			Usage:  "maximum number of parallel queries on MongoDB",
			EnvVar: "HOOKY_MAX_MONGO_QUERY",
		},
		cli.IntFlag{
			Name:   "max-http-request",
			Value:  20,
			Usage:  "maximum number of parallel HTTP requests",
			EnvVar: "HOOKY_MAX_HTTP_REQUEST",
		},
		cli.IntFlag{
			Name:   "touch-interval",
			Value:  5,
			Usage:  "frequency to update the tasks reservation duration in seconds",
			EnvVar: "HOOKY_TOUCH_INTERVAL",
		},
	}
	app.Action = func(c *cli.Context) {
		s, err := store.New(c.String("mongo-uri"))
		if err != nil {
			log.Fatal(err)
		}
		sched := scheduler.New(s, c.Int("max-mongo-query"), c.Int("max-http-request"), c.Int("touch-interval"))
		sched.Start()
		ra, err := restapi.New(s, c.String("admin-password"))
		if err != nil {
			log.Fatal(err)
		}
		server := &graceful.Server{
			Timeout: 10 * time.Second,
			Server: &http.Server{
				Addr:    c.String("bind"),
				Handler: ra.MakeHandler(),
			},
		}
		server.ListenAndServe()
		fmt.Println("exiting")
		sched.Stop()
		fmt.Println("exited")
	}
	app.Run(os.Args)
}

{'fraction_non_alphanumeric': 0.16687041564792177, 'fraction_numerical': 0.006723716381418093, 'mean_word_length': 3.57122905027933, 'pattern_counts': {'":': 2, '<': 8, '<?xml version=': 0, '>': 8, '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': '3991928', 'n_tokens_mistral': 1406, 'n_tokens_neox': 1277, 'n_words': 257}