mm_monitor 1.0.2 → 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.
Files changed (2) hide show
  1. package/index.js +8 -3
  2. 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
- await this.notiy(o);
108
- hasBug = true;
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_monitor",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "超级美眉监听器,用于监听网站运行是否异常并给运维人员发短信、邮箱通知",
5
5
  "main": "index.js",
6
6
  "scripts": {