package main

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

	"code.ivysaur.me/trpcd"
)

func main() {

	listenAddr := flag.String("Listen", `127.0.0.1:9091`, "")
	sessionPruneSeconds := flag.Int("Prune", 30, "Prune sessions after inactivity (seconds)")
	baseDir := flag.String("Basedir", "/", "")
	flag.Parse()

	dataSource := NewSampleDataProvider()

	server, err := trpcd.NewServer(dataSource, *sessionPruneSeconds, *baseDir)
	if err != nil {
		log.Fatal(err.Error())
	}

	err = http.ListenAndServe(*listenAddr, server.ServeMux())
	log.Fatal(err)
}
