You've already forked speedtest-go
Add option to specify config file
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user