mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-12-24 23:09:39 -05:00
prevent unexpected error throw from checkCertificate interrupt the beat
This commit is contained in:
parent
51ac7a58dc
commit
caec933186
@ -6,7 +6,7 @@ var timezone = require('dayjs/plugin/timezone')
|
|||||||
dayjs.extend(utc)
|
dayjs.extend(utc)
|
||||||
dayjs.extend(timezone)
|
dayjs.extend(timezone)
|
||||||
const axios = require("axios");
|
const axios = require("axios");
|
||||||
const {UP, DOWN, PENDING} = require("../util");
|
const {debug, UP, DOWN, PENDING} = require("../util");
|
||||||
const {tcping, ping, checkCertificate} = require("../util-server");
|
const {tcping, ping, checkCertificate} = require("../util-server");
|
||||||
const {R} = require("redbean-node");
|
const {R} = require("redbean-node");
|
||||||
const {BeanModel} = require("redbean-node/dist/bean-model");
|
const {BeanModel} = require("redbean-node/dist/bean-model");
|
||||||
@ -89,9 +89,17 @@ class Monitor extends BeanModel {
|
|||||||
bean.ping = dayjs().valueOf() - startTime;
|
bean.ping = dayjs().valueOf() - startTime;
|
||||||
|
|
||||||
// Check certificate if https is used
|
// Check certificate if https is used
|
||||||
|
|
||||||
|
let certInfoStartTime = dayjs().valueOf();
|
||||||
if (this.getUrl()?.protocol === "https:") {
|
if (this.getUrl()?.protocol === "https:") {
|
||||||
|
try {
|
||||||
await this.updateTlsInfo(checkCertificate(res));
|
await this.updateTlsInfo(checkCertificate(res));
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e.message)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
debug("Cert Info Query Time: " + (dayjs().valueOf() - certInfoStartTime) + "ms")
|
||||||
|
|
||||||
if (this.type === "http") {
|
if (this.type === "http") {
|
||||||
bean.status = UP;
|
bean.status = UP;
|
||||||
@ -228,7 +236,7 @@ class Monitor extends BeanModel {
|
|||||||
tls_info_bean.monitor_id = this.id;
|
tls_info_bean.monitor_id = this.id;
|
||||||
}
|
}
|
||||||
tls_info_bean.info_json = JSON.stringify(checkCertificateResult);
|
tls_info_bean.info_json = JSON.stringify(checkCertificateResult);
|
||||||
R.store(tls_info_bean);
|
await R.store(tls_info_bean);
|
||||||
}
|
}
|
||||||
|
|
||||||
static async sendStats(io, monitorID, userID) {
|
static async sendStats(io, monitorID, userID) {
|
||||||
|
@ -18,3 +18,9 @@ exports.ucfirst = function (str) {
|
|||||||
return firstLetter.toUpperCase() + str.substr(1);
|
return firstLetter.toUpperCase() + str.substr(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exports.debug = (msg) => {
|
||||||
|
if (process.env.NODE_ENV === "development") {
|
||||||
|
console.log(msg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user