diff --git a/src/models.go b/src/models.go index 687e582..7afcde3 100644 --- a/src/models.go +++ b/src/models.go @@ -9,8 +9,9 @@ import ( type Instance struct { // Settings required by the user. - Debug bool - DB *DB + Debug bool + DB *DB + PrivServersFile string // Internal stuff addr string diff --git a/src/updater.go b/src/updater.go index 6f8ceff..ccae4a8 100644 --- a/src/updater.go +++ b/src/updater.go @@ -7,8 +7,6 @@ import ( var updatedservers []string -const SERVERS_CONFIG = "./servers.json" // TODO - type RawServerData struct { Title string Game_url string @@ -22,7 +20,7 @@ func (i *Instance) UpdateServers() { tx := i.DB.NewTransaction() - config, err := LoadConfig(SERVERS_CONFIG) + config, err := LoadConfig(i.PrivServersFile) if !log_error(err) { if i.Debug { fmt.Println("\nPolling servers...") diff --git a/ss13.go b/ss13.go index 0e4f3e7..a7e250e 100644 --- a/ss13.go +++ b/ss13.go @@ -36,6 +36,16 @@ func main() { Usage: "Time (in minutes) between each update in daemon mode", Value: 15, }, + cli.StringFlag{ + Name: "private-servers", + Usage: "JSON file with a list of private servers to poll", + Value: "./servers.json", + }, + cli.StringFlag{ + Name: "database", + Usage: "Database file", + Value: "./ss13.db", + }, } app.Commands = []cli.Command{ { @@ -59,8 +69,9 @@ func run_server(c *cli.Context) { } instance := &ss13.Instance{ - Debug: c.GlobalBool("debug"), - DB: ss13.OpenSqliteDB("new.db"), // TODO + Debug: c.GlobalBool("debug"), + DB: ss13.OpenSqliteDB(c.GlobalString("database")), + PrivServersFile: c.GlobalString("private-servers"), } instance.Init() instance.Serve(c.GlobalString("addr")) @@ -77,8 +88,9 @@ func update_stats(c *cli.Context) { } instance := &ss13.Instance{ - Debug: c.GlobalBool("debug"), - DB: ss13.OpenSqliteDB("new.db"), // TODO + Debug: c.GlobalBool("debug"), + DB: ss13.OpenSqliteDB(c.GlobalString("database")), + PrivServersFile: c.GlobalString("private-servers"), } instance.Init()