Fix hardcoded file paths.
This commit is contained in:
parent
166215a6f4
commit
549c5b3599
@ -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
|
||||
|
||||
@ -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...")
|
||||
|
||||
20
ss13.go
20
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()
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user