Add option to specify config file

This commit is contained in:
Maddie Zhan
2020-06-16 16:10:58 +08:00
parent bd721cdb07
commit 60329fc832
3 changed files with 45 additions and 11 deletions
+16 -2
View File
@@ -1,6 +1,8 @@
package main
import (
"flag"
"github.com/librespeed/speedtest/config"
"github.com/librespeed/speedtest/database"
"github.com/librespeed/speedtest/results"
@@ -9,9 +11,21 @@ import (
log "github.com/sirupsen/logrus"
)
func main() {
conf := config.Load()
var (
optConfig = flag.String("c", "", "config file to be used, defaults to settings.toml in the same directory")
)
func main() {
flag.Parse()
var conf config.Config
if *optConfig != "" {
conf = config.LoadFile(*optConfig)
} else {
conf = config.Load()
}
web.SetServerLocation(&conf)
results.Initialize(&conf)
database.SetDBInfo(&conf)
log.Fatal(web.ListenAndServe(&conf))