Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
AppMonitorSubscriber
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nongyingchen
AppMonitorSubscriber
Commits
46a84a67
Commit
46a84a67
authored
May 23, 2019
by
trace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add log time
parent
b8bb4f4a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
15 deletions
+15
-15
play.js
+15
-15
No files found.
play.js
View file @
46a84a67
...
@@ -87,8 +87,8 @@ let allNames = names => {
...
@@ -87,8 +87,8 @@ let allNames = names => {
return
Array
.
from
(
new
Set
(
an
))
return
Array
.
from
(
new
Set
(
an
))
}
}
function
log
(
content
)
{
function
log
(
content
,
useRelease
=
false
)
{
if
(
isTest
())
{
if
(
isTest
()
||
useRelease
)
{
console
.
log
(
`[
${
new
Date
().
toLocaleString
()}
]:
${
content
}
`
)
console
.
log
(
`[
${
new
Date
().
toLocaleString
()}
]:
${
content
}
`
)
}
}
}
}
...
@@ -108,7 +108,7 @@ try {
...
@@ -108,7 +108,7 @@ try {
isFirstRun
=
false
isFirstRun
=
false
}
catch
(
err
)
{
}
catch
(
err
)
{
isFirstRun
=
true
isFirstRun
=
true
console
.
log
(
`状态文件不存在, 直接使用空的{}\n
${
err
.
toString
()}
`
)
log
(
`状态文件不存在, 直接使用空的{}\n
${
err
.
toString
()}
`
,
true
)
}
}
// 获取记录上次更新监控名得文件
// 获取记录上次更新监控名得文件
...
@@ -116,13 +116,13 @@ try {
...
@@ -116,13 +116,13 @@ try {
let
fileNames
=
JSON
.
parse
(
fs
.
readFileSync
(
monitorApps
,
'utf-8'
))
let
fileNames
=
JSON
.
parse
(
fs
.
readFileSync
(
monitorApps
,
'utf-8'
))
if
(
Array
.
isArray
(
fileNames
))
{
if
(
Array
.
isArray
(
fileNames
))
{
monitorNames
[
'vn'
]
=
fileNames
monitorNames
[
'vn'
]
=
fileNames
console
.
log
(
'原来只记录数组形式, 现在变更为对象形式, 原数组放到vn数组中'
)
log
(
'原来只记录数组形式, 现在变更为对象形式, 原数组放到vn数组中'
,
true
)
}
else
{
}
else
{
monitorNames
=
fileNames
monitorNames
=
fileNames
}
}
isFirstRun
=
false
isFirstRun
=
false
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
log
(
`监控列表文件不存在, 直接使用空的{}\n
${
err
.
toString
()}
`
)
log
(
`监控列表文件不存在, 直接使用空的{}\n
${
err
.
toString
()}
`
,
true
)
}
}
let
newOnline
=
[]
// 新上架
let
newOnline
=
[]
// 新上架
let
newOffline
=
[]
// 新下架
let
newOffline
=
[]
// 新下架
...
@@ -180,7 +180,7 @@ async function startMonitor() {
...
@@ -180,7 +180,7 @@ async function startMonitor() {
lastIntervalTime
=
lastIntervalTime
*
2
lastIntervalTime
=
lastIntervalTime
*
2
let
content
=
`监控出错
${
err
}
\n间隔时间调整为
${(
lastIntervalTime
)
/
minute
}
分钟`
let
content
=
`监控出错
${
err
}
\n间隔时间调整为
${(
lastIntervalTime
)
/
minute
}
分钟`
content
+=
markError
()
content
+=
markError
()
console
.
log
(
content
)
log
(
content
,
true
)
sendEmail
(
content
,
developer
)
sendEmail
(
content
,
developer
)
dingDing
(
content
)
dingDing
(
content
)
if
(
err
.
toString
().
includes
(
'ENOSPC'
))
{
if
(
err
.
toString
().
includes
(
'ENOSPC'
))
{
...
@@ -410,7 +410,7 @@ async function getTop100() {
...
@@ -410,7 +410,7 @@ async function getTop100() {
requestOptions
:
{
timeout
:
requestTimeout
}
requestOptions
:
{
timeout
:
requestTimeout
}
})
})
.
then
(
res
=>
{
.
then
(
res
=>
{
console
.
log
(
`获取到 <
${
monitorRegion
[
region
]}
>[
${
monitorType
[
type
]}
]排名:
${
i
*
120
}
~
${
i
*
120
+
getNum
}
`
)
log
(
`获取到 <
${
monitorRegion
[
region
]}
>[
${
monitorType
[
type
]}
]排名:
${
i
*
120
}
~
${
i
*
120
+
getNum
}
`
,
true
)
if
(
res
&&
res
.
length
&&
res
.
length
>
0
)
{
if
(
res
&&
res
.
length
&&
res
.
length
>
0
)
{
res
.
forEach
(
app
=>
{
res
.
forEach
(
app
=>
{
...
@@ -429,7 +429,7 @@ async function getTop100() {
...
@@ -429,7 +429,7 @@ async function getTop100() {
}
}
})
})
.
catch
(
err
=>
{
.
catch
(
err
=>
{
console
.
log
(
`获取排名<
${
monitorRegion
[
region
]}
> 错误:
${
err
.
message
}
`
)
log
(
`获取排名<
${
monitorRegion
[
region
]}
> 错误:
${
err
.
message
}
`
,
true
)
throw
err
throw
err
})
})
}
}
...
@@ -470,17 +470,17 @@ async function monitorIfOnline(names) {
...
@@ -470,17 +470,17 @@ async function monitorIfOnline(names) {
})
})
.
catch
((
err
)
=>
{
.
catch
((
err
)
=>
{
if
(
err
.
toString
().
includes
(
'404'
))
{
if
(
err
.
toString
().
includes
(
'404'
))
{
console
.
log
(
`获取不到:
${
name
}
, error:
${
err
}
`
)
log
(
`获取不到:
${
name
}
, error:
${
err
}
`
,
true
)
failedApps
.
push
(
name
)
failedApps
.
push
(
name
)
judgeNewOffline
(
name
)
judgeNewOffline
(
name
)
let
a
=
status
[
name
]
||
{}
let
a
=
status
[
name
]
||
{}
status
[
name
]
=
{
...
a
,
status
:
false
,
date
:
Date
().
toString
()
}
status
[
name
]
=
{
...
a
,
status
:
false
,
date
:
Date
().
toString
()
}
}
else
if
(
err
.
toString
().
includes
(
'ETIMEDOUT'
))
{
}
else
if
(
err
.
toString
().
includes
(
'ETIMEDOUT'
))
{
console
.
log
(
`连接超时:
${
err
.
toString
()}
`
)
log
(
`连接超时:
${
err
.
toString
()}
`
,
true
)
throw
err
throw
err
}
else
{
}
else
{
errorLog
.
push
(
`Motitor Online Error:
${
link
(
name
,
true
)}
-
${
err
.
message
}
`
)
errorLog
.
push
(
`Motitor Online Error:
${
link
(
name
,
true
)}
-
${
err
.
message
}
`
)
console
.
log
(
`获取在线错误:
${
name
}
,
${
err
.
message
}
`
)
log
(
`获取在线错误:
${
name
}
,
${
err
.
message
}
`
,
true
)
}
}
})
})
}
}
...
@@ -720,7 +720,7 @@ function aliveContent(date, lastSend) {
...
@@ -720,7 +720,7 @@ function aliveContent(date, lastSend) {
function
sendEmail
(
content
,
to
=
notifyEmail
)
{
function
sendEmail
(
content
,
to
=
notifyEmail
)
{
if
(
content
==
null
||
content
==
undefined
||
content
==
''
)
{
if
(
content
==
null
||
content
==
undefined
||
content
==
''
)
{
console
.
log
(
'没有生成内容, 检查心跳'
)
log
(
'没有生成内容, 检查心跳'
,
true
)
let
date
=
new
Date
()
let
date
=
new
Date
()
let
lastDing
=
new
Date
(
status
.
lastDingDate
||
'Tue Jan 29 2019 19:32:24 GMT+0800 (CST)'
)
let
lastDing
=
new
Date
(
status
.
lastDingDate
||
'Tue Jan 29 2019 19:32:24 GMT+0800 (CST)'
)
let
lastSend
=
new
Date
(
status
.
lastSendDate
||
'Tue Jan 29 2019 19:32:24 GMT+0800 (CST)'
)
let
lastSend
=
new
Date
(
status
.
lastSendDate
||
'Tue Jan 29 2019 19:32:24 GMT+0800 (CST)'
)
...
@@ -744,7 +744,7 @@ function sendEmail(content, to = notifyEmail) {
...
@@ -744,7 +744,7 @@ function sendEmail(content, to = notifyEmail) {
}
}
return
return
}
}
console
.
log
(
`发送email:
${
content
.
length
}
`
)
log
(
`发送email:
${
content
.
length
}
`
,
true
)
// if (content.indexOf('Error') != -1) {
// if (content.indexOf('Error') != -1) {
// to = developer
// to = developer
// } else {
// } else {
...
@@ -776,9 +776,9 @@ function sendEmail(content, to = notifyEmail) {
...
@@ -776,9 +776,9 @@ function sendEmail(content, to = notifyEmail) {
trans
.
sendMail
(
mailOption
,
(
error
,
info
)
=>
{
trans
.
sendMail
(
mailOption
,
(
error
,
info
)
=>
{
if
(
error
)
{
if
(
error
)
{
return
console
.
log
(
`发生错误:
${
error
}
`
);
return
log
(
`发生错误:
${
error
}
`
,
true
);
}
}
console
.
log
(
`message
${
info
.
messageId
}
send:
${
info
.
response
}
`
)
log
(
`message
${
info
.
messageId
}
send:
${
info
.
response
}
`
,
true
)
})
})
dingDing
(
content
,
notifyDingding
)
dingDing
(
content
,
notifyDingding
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment