Skip to content

Commit

Permalink
option to disable the reload (#14) (#15)
Browse files Browse the repository at this point in the history
Co-authored-by: Andy Baer <[email protected]>
  • Loading branch information
snorwin and m-terra authored Oct 30, 2024
1 parent 0acc0e4 commit 13955ce
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
13 changes: 9 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,16 @@ func main() {
log.Notice(fmt.Sprintf("fsnotify watcher create failed : %v", err))
os.Exit(1)
}
if err := fswatch.Add(watchPath); err != nil {
log.Notice(fmt.Sprintf("watch failed : %v", err))
os.Exit(1)

if utils.DisableReload() {
log.Notice("reload disabled, no watches added")
} else {
if err := fswatch.Add(watchPath); err != nil {
log.Notice(fmt.Sprintf("watch failed : %v", err))
os.Exit(1)
}
log.Notice(fmt.Sprintf("watch : %s", watchPath))
}
log.Notice(fmt.Sprintf("watch : %s", watchPath))

// flag used for termination handling
var terminated bool
Expand Down
7 changes: 7 additions & 0 deletions pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,10 @@ func LoadEnvFile() []string {

return env
}

func DisableReload() bool {
if str, ok := os.LookupEnv("DISABLE_RELOAD"); ok {
return strings.EqualFold(str, "true")
}
return false
}

0 comments on commit 13955ce

Please sign in to comment.