mm_monitor 1.0.3 → 1.0.4

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 (3) hide show
  1. package/config.json +14 -2
  2. package/index.js +13 -9
  3. package/package.json +1 -1
package/config.json CHANGED
@@ -29,7 +29,19 @@
29
29
  // "phone": "",
30
30
  // // 推送的内容
31
31
  // "content": "服务器异常,请尽快进行维护!--考勤系统"
32
- // }
32
+ // },
33
+ {
34
+ // 网站名称
35
+ "name": "考勤系统",
36
+ // URL地址
37
+ "url": "https://faces.aieliantong.com/api/face/project?size=1",
38
+ // 推送到邮箱
39
+ "email": "573242395@qq.com",
40
+ // 发送短信到
41
+ "phone": "15817188815",
42
+ // 推送的内容
43
+ "content": "服务器异常,请尽快进行维护!--考勤系统"
44
+ }
33
45
  ],
34
- "interval": 3
46
+ "interval": 30
35
47
  }
package/index.js CHANGED
@@ -104,11 +104,15 @@ Monitor.prototype.loop = async function() {
104
104
  try {
105
105
  var bl = await this.checkServer(o.url);
106
106
  if (!bl) {
107
- console.log("发生异常", (new Date()).toStr('yyyy-MM-dd hh:mm:ss'), o);
108
- if (!this.sended) {
109
- this.sended = true;
110
- await this.notiy(o);
111
- hasBug = true;
107
+ $.sleep(1000);
108
+ bl = await this.checkServer(o.url);
109
+ if (!bl) {
110
+ console.log("发生异常", (new Date()).toStr('yyyy-MM-dd hh:mm:ss'), o);
111
+ if (!this.sended) {
112
+ this.sended = true;
113
+ await this.notiy(o);
114
+ hasBug = true;
115
+ }
112
116
  }
113
117
  }
114
118
  } catch (err) {
@@ -120,8 +124,8 @@ Monitor.prototype.loop = async function() {
120
124
  // 如果出现异常,则先暂停运行
121
125
  clearInterval(this.timer);
122
126
  // 等过了N久后再运行,避免连续通知
123
- setTimeout(() => {
124
- this.run();
127
+ setTimeout(async () => {
128
+ await this.run();
125
129
  }, this.config.interval_again * 1000);
126
130
  }
127
131
  }
@@ -131,8 +135,8 @@ Monitor.prototype.loop = async function() {
131
135
  */
132
136
  Monitor.prototype.run = async function() {
133
137
  this.sended = false;
134
- this.timer = setInterval(() => {
135
- this.loop();
138
+ this.timer = setInterval(async () => {
139
+ await this.loop();
136
140
  }, this.config.interval * 1000);
137
141
  }
138
142
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_monitor",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "超级美眉监听器,用于监听网站运行是否异常并给运维人员发短信、邮箱通知",
5
5
  "main": "index.js",
6
6
  "scripts": {