Skip to content

Commit

Permalink
Renaming gnatsd files to nats. Adding config file extension check
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelattwood committed Jan 24, 2024
1 parent 40212e8 commit 2d5c185
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cmd/nats-server-config-reloader/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ func main() {
fs.BoolVar(&showVersion, "v", false, "Show version")
fs.BoolVar(&showVersion, "version", false, "Show version")

fs.StringVar(&nconfig.PidFile, "P", "/var/run/nats/gnatsd.pid", "NATS Server Pid File")
fs.StringVar(&nconfig.PidFile, "pid", "/var/run/nats/gnatsd.pid", "NATS Server Pid File")
fs.StringVar(&nconfig.PidFile, "P", "/var/run/nats/nats.pid", "NATS Server Pid File")
fs.StringVar(&nconfig.PidFile, "pid", "/var/run/nats/nats.pid", "NATS Server Pid File")
fs.Var(&fileSet, "c", "NATS Server Config File (may be repeated to specify more than one)")
fs.Var(&fileSet, "config", "NATS Server Config File (may be repeated to specify more than one)")
fs.IntVar(&nconfig.MaxRetries, "max-retries", 30, "Max attempts to trigger reload")
Expand All @@ -66,7 +66,7 @@ func main() {

nconfig.WatchedFiles = fileSet
if len(fileSet) == 0 {
nconfig.WatchedFiles = []string{"/etc/nats-config/gnatsd.conf"}
nconfig.WatchedFiles = []string{"/etc/nats-config/nats.conf"}
}
nconfig.Signal = syscall.Signal(customSignal)

Expand Down
5 changes: 5 additions & 0 deletions pkg/natsreloader/natsreloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"regexp"
"sort"
"strconv"
"strings"
"syscall"
"time"

Expand Down Expand Up @@ -217,6 +218,10 @@ func (r *Reloader) init() (*fsnotify.Watcher, map[string][]byte, error) {
watchedFiles := make([]string, 0)

for _, c := range r.WatchedFiles {
// Only try to parse config files
if !strings.HasSuffix(c, ".conf") {
continue
}
childFiles, err := getServerFiles(c)
if err != nil {
return nil, nil, err
Expand Down

0 comments on commit 2d5c185

Please sign in to comment.