Adds cmd flags to change addr/path

This commit is contained in:
A. Svensson 2017-07-15 18:15:45 +02:00
parent 5d07c05648
commit aa725ad809

View File

@ -1,20 +1,28 @@
package main package main
import ( import (
"flag"
"time" "time"
"github.com/lmas/ss13_se" "github.com/lmas/ss13_se"
) )
var (
flagAddr = flag.String("addr", ":8000", "Adress and port to run the web server on")
flagPath = flag.String("path", "servers.db", "File path to database")
)
func main() { func main() {
flag.Parse()
// TODO: load config from a toml file // TODO: load config from a toml file
conf := ss13_se.Conf{ conf := ss13_se.Conf{
WebAddr: ":8000", WebAddr: *flagAddr,
ReadTimeout: 30 * time.Second, ReadTimeout: 30 * time.Second,
WriteTimeout: 30 * time.Second, WriteTimeout: 30 * time.Second,
ScrapeTimeout: 10 * time.Minute, ScrapeTimeout: 10 * time.Minute,
Storage: &ss13_se.StorageSqlite{ Storage: &ss13_se.StorageSqlite{
Path: "./tmp/servers.db", Path: *flagPath,
}, },
} }
app, err := ss13_se.New(conf) app, err := ss13_se.New(conf)