Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADDED] Print the config file being used in startup banner #1473

Merged
merged 2 commits into from Jun 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions server/gateway_test.go
Expand Up @@ -2501,16 +2501,17 @@ func TestGatewaySendRemoteQSubs(t *testing.T) {
// Server sb1 should not have qsub in its sub interest map
checkFor(t, time.Second, 15*time.Millisecond, func() error {
var entry *sitally
var err error
sb1.gateway.pasi.Lock()
asim := sb1.gateway.pasi.m[globalAccountName]
if asim != nil {
entry = asim["foo bar"]
}
sb1.gateway.pasi.Unlock()
if entry != nil {
return fmt.Errorf("Map should not have an entry, got %#v", entry)
err = fmt.Errorf("Map should not have an entry, got %#v", entry)
}
return nil
sb1.gateway.pasi.Unlock()
return err
})

// Let's wait for A to receive the unsubscribe
Expand Down
4 changes: 4 additions & 0 deletions server/server.go
Expand Up @@ -1244,6 +1244,10 @@ func (s *Server) Start() {
// Snapshot server options.
opts := s.getOpts()

if opts.ConfigFile != _EMPTY_ {
s.Noticef("Using configuration file: %s", opts.ConfigFile)
}

hasOperators := len(opts.TrustedOperators) > 0
if hasOperators {
s.Noticef("Trusted Operators")
Expand Down
34 changes: 34 additions & 0 deletions server/server_test.go
Expand Up @@ -1747,3 +1747,37 @@ func TestReconnectErrorReports(t *testing.T) {
})
}
}

func TestServerLogsConfigurationFile(t *testing.T) {
tmpDir, err := ioutil.TempDir("", "_nats-server")
if err != nil {
t.Fatal("Could not create tmp dir")
}
defer os.RemoveAll(tmpDir)

file, err := ioutil.TempFile(tmpDir, "nats_server_log_")
if err != nil {
t.Fatalf("Could not create the temp file: %v", err)
}
file.Close()

conf := createConfFile(t, []byte(fmt.Sprintf(`
port: -1
logfile: "%s"
`, file.Name())))
defer os.Remove(conf)

o := LoadConfig(conf)
o.ConfigFile = file.Name()
o.NoLog = false
s := RunServer(o)
s.Shutdown()

log, err := ioutil.ReadFile(file.Name())
if err != nil {
t.Fatalf("Error reading log file: %v", err)
}
if !bytes.Contains(log, []byte(fmt.Sprintf("Using configuration file: %s", file.Name()))) {
t.Fatalf("Config file location was not reported in log: %s", log)
}
}