mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-09-07 18:02:42 +00:00
prevent monitor dead for unexpected error
This commit is contained in:
parent
234fba3978
commit
640b6e5b1c
@ -387,18 +387,32 @@ class Monitor extends BeanModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.heartbeatInterval = setTimeout(beat, beatInterval * 1000);
|
this.heartbeatInterval = setTimeout(safeBeat, beatInterval * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const safeBeat = async () => {
|
||||||
|
try {
|
||||||
|
await beat();
|
||||||
|
} catch (e) {
|
||||||
|
console.trace(e);
|
||||||
|
console.error("Please report to https://github.com/louislam/uptime-kuma/issues");
|
||||||
|
|
||||||
|
if (! this.isStop) {
|
||||||
|
console.log("Try to restart the monitor");
|
||||||
|
this.heartbeatInterval = setTimeout(safeBeat, this.interval * 1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Delay Push Type
|
// Delay Push Type
|
||||||
if (this.type === "push") {
|
if (this.type === "push") {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
beat();
|
safeBeat();
|
||||||
}, this.interval * 1000);
|
}, this.interval * 1000);
|
||||||
} else {
|
} else {
|
||||||
beat();
|
safeBeat();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user