Config file support for monitor http port

This commit is contained in:
Derek Collison
2013-07-30 18:04:33 -07:00
parent 320f03d22b
commit c07bca3144
5 changed files with 17 additions and 7 deletions

View File

@@ -87,7 +87,7 @@ func main() {
s.StartRouting()
}
// Profiler
// Pprof http endpoint for the profiler.
go func() {
log.Println(http.ListenAndServe("localhost:6062", nil))
}()

View File

@@ -4,6 +4,8 @@
port: 4242
net: apcera.me # net interface
http_port: 8222
authorization {
user: derek
password: bella

View File

@@ -82,6 +82,8 @@ func ProcessConfigFile(configFile string) (*Options, error) {
opts.Username = auth.user
opts.Password = auth.pass
opts.AuthTimeout = auth.timeout
case "http_port", "monitor_port":
opts.HttpPort = int(v.(int64))
case "cluster":
cm := v.(map[string]interface{})
if err := parseCluster(cm, opts); err != nil {

View File

@@ -39,6 +39,7 @@ func TestConfigFile(t *testing.T) {
Debug: false,
Trace: true,
Logtime: false,
HttpPort: 8222,
}
opts, err := ProcessConfigFile("./configs/test.conf")
@@ -47,7 +48,8 @@ func TestConfigFile(t *testing.T) {
}
if !reflect.DeepEqual(golden, opts) {
t.Fatal("Options are incorrect from config file")
t.Fatalf("Options are incorrect.\nexpected: %+v\ngot: %+v",
golden, opts)
}
}
@@ -61,6 +63,7 @@ func TestMergeOverrides(t *testing.T) {
Debug: true,
Trace: true,
Logtime: false,
HttpPort: DEFAULT_HTTP_PORT,
}
fopts, err := ProcessConfigFile("./configs/test.conf")
if err != nil {
@@ -69,12 +72,15 @@ func TestMergeOverrides(t *testing.T) {
// Overrides via flags
opts := &Options{
Port: 2222,
Password: "spooky",
Debug: true,
Port: 2222,
Password: "spooky",
Debug: true,
HttpPort: DEFAULT_HTTP_PORT,
}
merged := MergeOptions(fopts, opts)
if !reflect.DeepEqual(golden, merged) {
t.Fatal("Options are incorrect from config file")
t.Fatalf("Options are incorrect.\nexpected: %+v\ngot: %+v",
golden, merged)
}
}

View File

@@ -34,7 +34,7 @@ func TestRouteConfig(t *testing.T) {
golden.Routes = []*url.URL{r1, r2}
if !reflect.DeepEqual(golden, opts) {
t.Fatalf("Options are incorrect from config file.\nexpected: %+v\ngot: %+v",
t.Fatalf("Options are incorrect.\nexpected: %+v\ngot: %+v",
golden, opts)
}
}