From 2ffb2dce486c4733eb910aa451fb53eba848acf5 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Thu, 20 Jun 2019 17:16:17 -0600 Subject: [PATCH] log hiccups, downtime, and unrecoverable downtime --- build.go | 8 ++++++++ watchdog.go | 10 ++++++++++ 2 files changed, 18 insertions(+) create mode 100644 build.go diff --git a/build.go b/build.go new file mode 100644 index 0000000..076c4c3 --- /dev/null +++ b/build.go @@ -0,0 +1,8 @@ +//go:generate go build -o watchdog cmd/watchdog/watchdog.go + +package watchdog + +// This is takes the place of a makefile. + +// Usage: +// go generate -mod=vendor build.go diff --git a/watchdog.go b/watchdog.go index 86f77c4..2a7806d 100644 --- a/watchdog.go +++ b/watchdog.go @@ -52,6 +52,15 @@ func (d *Dog) watch() { return } + time.Sleep(time.Duration(2) * time.Second) + err2 := d.check() + if nil != err { + d.Logger <- fmt.Sprintf("Down: '%s': %s", d.Name, err2) + } else { + d.Logger <- fmt.Sprintf("Hiccup: '%s': %s", d.Name, err) + return + } + failure := false t := 10 for { @@ -61,6 +70,7 @@ func (d *Dog) watch() { t *= 2 err := d.check() if nil != err { + d.Logger <- fmt.Sprintf("Unrecoverable: '%s': %s", d.Name, err) failure = true } else { failure = false