Skip to content

Commit 808a971

Browse files
authored
Refactor ping logic and add debug logging
Reorganize ping logic and maintain debug logging.
1 parent 723e478 commit 808a971

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

internals/server/http.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,13 @@ func httpHandler(w http.ResponseWriter, req *http.Request) {
121121
return
122122
}
123123

124-
logger.Debug("Pinging host again")
125-
126124
if body.StartupTime != nil {
127125
time.Sleep(time.Duration(*body.StartupTime) * time.Second)
126+
}
128127

128+
logger.Debug("Pinging host again")
129+
130+
if body.StartupTime != nil {
129131
reachable, err = tryPing(client, body.IP,
130132
func() (bool, error) {
131133
sendToClient(client, map[string]any{
@@ -224,4 +226,4 @@ func tryPing(client *websocket.Conn, addr string, reachable, unreachable func()
224226
} else {
225227
return unreachable()
226228
}
227-
}
229+
}

0 commit comments

Comments
 (0)