Skip to content

Commit 1820bb3

Browse files
committed
Don't spam log when hostname cannot resolve
1 parent 3e06254 commit 1820bb3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

cmd/serve.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,14 @@ func isAddressReachable(addr string) (bool, error) {
212212
pinger.Timeout = 2 * time.Second
213213
pinger.Count = 1
214214

215+
// We resolve first because a host that's currently off may not have a dns entry and we don't want to spam the log.
216+
// We could display this in the web interface in the future instead of ignoring it.
217+
pinger.ResolveTimeout = 2 * time.Second
218+
err = pinger.Resolve()
219+
if err != nil {
220+
return false, nil
221+
}
222+
215223
err = pinger.Run()
216224
if err != nil {
217225
return false, fmt.Errorf("error pinging: %v", err)

0 commit comments

Comments
 (0)