Skip to content

Commit 13955ce

Browse files
snorwinm-terra
andauthored
option to disable the reload (#14) (#15)
Co-authored-by: Andy Baer <andy.baer@gmail.com>
1 parent 0acc0e4 commit 13955ce

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

main.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,16 @@ func main() {
4343
log.Notice(fmt.Sprintf("fsnotify watcher create failed : %v", err))
4444
os.Exit(1)
4545
}
46-
if err := fswatch.Add(watchPath); err != nil {
47-
log.Notice(fmt.Sprintf("watch failed : %v", err))
48-
os.Exit(1)
46+
47+
if utils.DisableReload() {
48+
log.Notice("reload disabled, no watches added")
49+
} else {
50+
if err := fswatch.Add(watchPath); err != nil {
51+
log.Notice(fmt.Sprintf("watch failed : %v", err))
52+
os.Exit(1)
53+
}
54+
log.Notice(fmt.Sprintf("watch : %s", watchPath))
4955
}
50-
log.Notice(fmt.Sprintf("watch : %s", watchPath))
5156

5257
// flag used for termination handling
5358
var terminated bool

pkg/utils/utils.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,10 @@ func LoadEnvFile() []string {
5555

5656
return env
5757
}
58+
59+
func DisableReload() bool {
60+
if str, ok := os.LookupEnv("DISABLE_RELOAD"); ok {
61+
return strings.EqualFold(str, "true")
62+
}
63+
return false
64+
}

0 commit comments

Comments
 (0)