ss13_se/src/config.go
A. Svensson d2af505b0c Add TOML config and clean up startup.
- Removed servers.json and it's config code.
- Load the new config.toml, using TOML instead of JSON.
- Moved most of the cli flags to the config file.
- Simplified creation of a new server instance (using New()).
- Goroutine running updates was moved inside the lib.
2016-06-19 15:31:38 +02:00

37 lines
701 B
Go

package ss13
import "github.com/BurntSushi/toml"
type ServerConfig struct {
Title string
GameUrl string
SiteUrl string
}
type Config struct {
// Path to sqlite database file.
DatabasePath string
// Serve web pages on this address.
ListenAddr string
// List of "private" servers to manually poll for updates (private as
// in they do not show up on the byond hub page).
Servers []ServerConfig
// Update all servers every x minutes.
UpdateEvery int
// Timeout after x seconds, when trying to update a server.
UpdateTimeout int
}
func LoadConfig(path string) (*Config, error) {
c := Config{}
_, e := toml.DecodeFile(path, &c)
if e != nil {
return nil, e
}
return &c, nil
}