Skip to content

Commit b6e635e

Browse files
committed
Fix feedback from #87
This commit applies the feedback given in #87 and uses a flag to both add documentation and to match the style of the rest of the project. This change is only useful for exec healthchecks and not for http probes. Wherever possible users should only use http healthchecks since exec is very resource intensive. Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
1 parent f846f56 commit b6e635e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

main.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,21 @@ var (
2727
)
2828

2929
func main() {
30+
var runHealthcheck bool
31+
32+
flag.BoolVar(&runHealthcheck,
33+
"run-healthcheck",
34+
false,
35+
"Check for the a lock-file, when using an exec healthcheck. Exit 0 for present, non-zero when not found.")
36+
3037
flag.Parse()
3138

32-
switch flag.Arg(0) {
33-
case "healthcheck":
39+
if runHealthcheck {
3440
if lockFilePresent() {
3541
os.Exit(0)
3642
}
3743

44+
fmt.Fprintf(os.Stderr, "unable to find lock file.\n")
3845
os.Exit(1)
3946
}
4047

@@ -367,6 +374,7 @@ func makeStaticRequestHandler(watchdogConfig config.WatchdogConfig) http.Handler
367374

368375
func lockFilePresent() bool {
369376
path := filepath.Join(os.TempDir(), ".lock")
377+
370378
if _, err := os.Stat(path); os.IsNotExist(err) {
371379
return false
372380
}

0 commit comments

Comments
 (0)