Browse Source

Fix for push monitor logging UP statuses.

pull/699/head
Lukas 4 years ago
parent
commit
ac37326d9f
  1. 10
      server/model/monitor.js

10
server/model/monitor.js

@ -244,9 +244,10 @@ class Monitor extends BeanModel {
} else if (this.type === "push") { // Type: Push } else if (this.type === "push") { // Type: Push
const time = R.isoDateTime(dayjs.utc().subtract(this.interval, "second")); const time = R.isoDateTime(dayjs.utc().subtract(this.interval, "second"));
let heartbeatCount = await R.count("heartbeat", " monitor_id = ? AND time > ? ", [ let heartbeatCount = await R.count("heartbeat", " monitor_id = ? AND time > ? AND msg = ? ", [
this.id, this.id,
time time,
"OK"
]); ]);
debug("heartbeatCount " + heartbeatCount + " " + time); debug("heartbeatCount " + heartbeatCount + " " + time);
@ -254,10 +255,9 @@ class Monitor extends BeanModel {
if (heartbeatCount <= 0) { if (heartbeatCount <= 0) {
throw new Error("No heartbeat in the time window"); throw new Error("No heartbeat in the time window");
} else { } else {
// No need to insert successful heartbeat for push type, so end here
retries = 0; retries = 0;
this.heartbeatInterval = setTimeout(beat, this.interval * 1000); bean.status = UP;
return; bean.msg = "";
} }
} else { } else {

Loading…
Cancel
Save