mm_monitor 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +8 -3
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -48,7 +48,8 @@ class Monitor {
|
|
|
48
48
|
interval: 30,
|
|
49
49
|
interval_again: 3600
|
|
50
50
|
}
|
|
51
|
-
|
|
51
|
+
// 是否已发送,用于避免重复发送
|
|
52
|
+
this.sended = false;
|
|
52
53
|
this.init(config);
|
|
53
54
|
}
|
|
54
55
|
}
|
|
@@ -104,8 +105,11 @@ Monitor.prototype.loop = async function() {
|
|
|
104
105
|
var bl = await this.checkServer(o.url);
|
|
105
106
|
if (!bl) {
|
|
106
107
|
console.log("发生异常", (new Date()).toStr('yyyy-MM-dd hh:mm:ss'), o);
|
|
107
|
-
|
|
108
|
-
|
|
108
|
+
if (!this.sended) {
|
|
109
|
+
this.sended = true;
|
|
110
|
+
await this.notiy(o);
|
|
111
|
+
hasBug = true;
|
|
112
|
+
}
|
|
109
113
|
}
|
|
110
114
|
} catch (err) {
|
|
111
115
|
console.error(err);
|
|
@@ -126,6 +130,7 @@ Monitor.prototype.loop = async function() {
|
|
|
126
130
|
* 运行监听
|
|
127
131
|
*/
|
|
128
132
|
Monitor.prototype.run = async function() {
|
|
133
|
+
this.sended = false;
|
|
129
134
|
this.timer = setInterval(() => {
|
|
130
135
|
this.loop();
|
|
131
136
|
}, this.config.interval * 1000);
|