Address CR feedback

This commit is contained in:
Tyler Treat
2017-06-27 16:53:18 -05:00
parent dd3ad77ea8
commit 032b0b4cd7
3 changed files with 12 additions and 8 deletions

View File

@@ -257,13 +257,13 @@ func (s *Server) Reload() error {
// Apply flags over config file settings.
newOpts = MergeOptions(newOpts, FlagSnapshot)
processOptions(newOpts)
err = s.reloadOptions(newOpts)
if err == nil {
s.mu.Lock()
s.configTime = time.Now()
s.mu.Unlock()
if err := s.reloadOptions(newOpts); err != nil {
return err
}
return err
s.mu.Lock()
s.configTime = time.Now()
s.mu.Unlock()
return nil
}
// reloadOptions reloads the server config with the provided options. If an

View File

@@ -49,7 +49,7 @@ func (s *Server) handleSignals() {
// is empty, this will send the signal to the single running instance of
// gnatsd. If multiple instances are running, it returns an error. This returns
// an error if the given process is not running or the command is invalid.
func ProcessSignal(command Command, pidStr string) (err error) {
func ProcessSignal(command Command, pidStr string) error {
var pid int
if pidStr == "" {
pids, err := resolvePids()
@@ -77,6 +77,7 @@ func ProcessSignal(command Command, pidStr string) (err error) {
pid = p
}
var err error
switch command {
case CommandStop:
err = kill(pid, syscall.SIGKILL)
@@ -89,7 +90,7 @@ func ProcessSignal(command Command, pidStr string) (err error) {
default:
err = fmt.Errorf("unknown signal %q", command)
}
return
return err
}
// resolvePids returns the pids for all running gnatsd processes.

View File

@@ -72,6 +72,9 @@ func TestSignalToReloadConfig(t *testing.T) {
loaded := s.ConfigTime()
// Wait a bit to ensure ConfigTime changes.
time.Sleep(5 * time.Millisecond)
// This should cause config to be reloaded.
syscall.Kill(syscall.Getpid(), syscall.SIGHUP)
// Wait a bit for action to be performed