mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-02 03:38:42 -07:00
Config file support for monitor http port
This commit is contained in:
@@ -87,7 +87,7 @@ func main() {
|
||||
s.StartRouting()
|
||||
}
|
||||
|
||||
// Profiler
|
||||
// Pprof http endpoint for the profiler.
|
||||
go func() {
|
||||
log.Println(http.ListenAndServe("localhost:6062", nil))
|
||||
}()
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
port: 4242
|
||||
net: apcera.me # net interface
|
||||
|
||||
http_port: 8222
|
||||
|
||||
authorization {
|
||||
user: derek
|
||||
password: bella
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user