mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-02 11:48:43 -07:00
Address CR feedback
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user