Add flag for passing config file
parent
eb172097c4
commit
8826be4637
19
main.go
19
main.go
|
@ -2,18 +2,35 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
var BusClient *http.Client
|
var BusClient *http.Client
|
||||||
var Quays []Quay = []Quay{}
|
var Quays []Quay
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
var confFilename string
|
||||||
var port int
|
var port int
|
||||||
|
|
||||||
|
flag.StringVar(&confFilename, "c", "", "Path to the configuration file")
|
||||||
flag.IntVar(&port, "p", 4444, "The port to start the server on")
|
flag.IntVar(&port, "p", 4444, "The port to start the server on")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
if confFilename == "" {
|
||||||
|
fmt.Printf("No configuation file provided. Provide the path to a configuration file with the -c flag.\n")
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
conf, err := ReadConfigFromFile(confFilename)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("%v\n", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
Quays = conf.Quays
|
||||||
|
|
||||||
BusClient = &http.Client{}
|
BusClient = &http.Client{}
|
||||||
serveHttp(port)
|
serveHttp(port)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue