mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-16 19:14:41 -07:00
Fixing CEO's bugs
This commit is contained in:
10
gnatsd.go
10
gnatsd.go
@@ -45,15 +45,19 @@ func main() {
|
||||
opts.Trace, opts.Debug = true, true
|
||||
}
|
||||
|
||||
var fileOpts *Options
|
||||
var fileOpts *server.Options
|
||||
var err error
|
||||
|
||||
// Parse config if given
|
||||
if configFile != "" {
|
||||
fileOpts = server.processConfigFile(configFile)
|
||||
fileOpts, err = server.ProcessConfigFile(configFile)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Create the server with appropriate options.
|
||||
s := server.New(server.mergeOptions(fileOpts, &opts))
|
||||
s := server.New(server.MergeOptions(fileOpts, &opts))
|
||||
|
||||
// Start up the http server if needed.
|
||||
if opts.HttpPort != 0 {
|
||||
|
||||
@@ -32,7 +32,7 @@ type Options struct {
|
||||
}
|
||||
|
||||
// FIXME(dlc): Hacky
|
||||
func processConfigFile(configFile string) (*Options, error) {
|
||||
func ProcessConfigFile(configFile string) (*Options, error) {
|
||||
opts := &Options{}
|
||||
|
||||
if configFile == "" {
|
||||
@@ -86,7 +86,7 @@ func processConfigFile(configFile string) (*Options, error) {
|
||||
}
|
||||
|
||||
// Will merge two options giving preference to the flagOpts if the item is present.
|
||||
func mergeOptions(fileOpts, flagOpts *Options) *Options {
|
||||
func MergeOptions(fileOpts, flagOpts *Options) *Options {
|
||||
if fileOpts == nil {
|
||||
return flagOpts
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ func TestConfigFile(t *testing.T) {
|
||||
Logtime: false,
|
||||
}
|
||||
|
||||
opts, err := processConfigFile("./configs/test.conf")
|
||||
opts, err := ProcessConfigFile("./configs/test.conf")
|
||||
if err != nil {
|
||||
t.Fatalf("Received an error reading config file: %v\n", err)
|
||||
}
|
||||
@@ -62,7 +62,7 @@ func TestMergeOverrides(t *testing.T) {
|
||||
Trace: true,
|
||||
Logtime: false,
|
||||
}
|
||||
fopts, err := processConfigFile("./configs/test.conf")
|
||||
fopts, err := ProcessConfigFile("./configs/test.conf")
|
||||
if err != nil {
|
||||
t.Fatalf("Received an error reading config file: %v\n", err)
|
||||
}
|
||||
@@ -73,8 +73,8 @@ func TestMergeOverrides(t *testing.T) {
|
||||
Password: "spooky",
|
||||
Debug: true,
|
||||
}
|
||||
merged := mergeOptions(fopts, opts)
|
||||
merged := MergeOptions(fopts, opts)
|
||||
if !reflect.DeepEqual(golden, merged) {
|
||||
t.Fatal("Options are incorrect from config file")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user