- 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.
38 lines
592 B
Go
38 lines
592 B
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"log"
|
|
|
|
"github.com/lmas/ss13_se/src"
|
|
)
|
|
|
|
var (
|
|
fConfig = flag.String("config", "config.toml", "path to config file")
|
|
fDebug = flag.Bool("debug", false, "run in debug mode")
|
|
)
|
|
|
|
func main() {
|
|
flag.Parse()
|
|
|
|
ins, e := ss13.New(*fDebug, *fConfig)
|
|
CheckError(e)
|
|
|
|
if *fDebug {
|
|
Log("Updating servers every %d minutes", ins.Config.UpdateEvery)
|
|
Log("Listening on %s", ins.Config.ListenAddr)
|
|
}
|
|
e = ins.Run()
|
|
CheckError(e)
|
|
}
|
|
|
|
func Log(f string, args ...interface{}) {
|
|
log.Printf(f+"\n", args...)
|
|
}
|
|
|
|
func CheckError(e error) {
|
|
if e != nil {
|
|
panic(e)
|
|
}
|
|
}
|