Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
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
蒋勇
zhichan
Commits
c023532c
Commit
c023532c
authored
Sep 11, 2020
by
蒋勇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d
parent
fd33be43
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
17 deletions
+27
-17
taskexecutor/app/base/db/task.base.js
+4
-1
taskexecutor/app/base/db/task/monitor/monitorTask.js
+23
-16
No files found.
taskexecutor/app/base/db/task.base.js
View file @
c023532c
...
@@ -28,9 +28,12 @@ class TaskBase {
...
@@ -28,9 +28,12 @@ class TaskBase {
//任务打点
//任务打点
//key taskuptime
//key taskuptime
let
taskName
=
this
.
formatedTaskName
(
this
.
serviceName
)
let
taskName
=
this
.
formatedTaskName
(
this
.
serviceName
)
console
.
log
(
taskName
,
"vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv"
)
if
(
taskName
&&
taskName
.
trim
()
!=
""
)
{
if
(
taskName
&&
taskName
.
trim
()
!=
""
)
{
let
nowtime
=
Date
.
now
()
let
nowtime
=
Date
.
now
()
this
.
redisClient
.
hmset
(
"taskuptime"
,
{
taskName
:
nowtime
})
let
tp
=
{}
tp
[
taskName
]
=
nowtime
this
.
redisClient
.
hmset
(
"taskuptime"
,
tp
)
}
}
//订阅任务频道
//订阅任务频道
await
this
.
redisClient
.
subscribe
(
this
.
TASK_CHANNEL
);
await
this
.
redisClient
.
subscribe
(
this
.
TASK_CHANNEL
);
...
...
taskexecutor/app/base/db/task/monitor/monitorTask.js
View file @
c023532c
...
@@ -12,32 +12,39 @@ class MonitorTask extends TaskBase {
...
@@ -12,32 +12,39 @@ class MonitorTask extends TaskBase {
* @param {*} taskName
* @param {*} taskName
*/
*/
formatedTaskName
(
taskName
)
{
formatedTaskName
(
taskName
)
{
console
.
log
(
"formatedTaskName"
,
"ddddddddddddddddddd"
)
return
taskName
+
"|i|10"
return
taskName
+
"|i|10"
}
}
isFail
(
taskName
,
lastAccess
)
{
isFail
(
taskName
,
lastAccess
)
{
let
n
=
Date
.
now
()
let
n
=
Date
.
now
()
let
postMinute
=
(
n
-
lastAccess
)
/
1000
/
60
let
postMinute
=
(
n
-
lastAccess
)
/
1000
/
60
let
tnameparams
=
taskName
.
split
(
"|"
)
let
tnameparams
=
taskName
.
split
(
"|"
)
let
tname
=
tnameparams
[
0
].
trim
()
if
(
tnameparams
.
length
==
3
)
{
let
mtype
=
tnameparams
[
1
].
trim
()
let
tname
=
tnameparams
[
0
].
trim
()
let
pvalue
=
Number
(
tnameparams
[
2
].
trim
())
let
mtype
=
tnameparams
[
1
].
trim
()
if
(
mtype
==
"i"
)
{
//每几分钟执行一次
let
pvalue
=
Number
(
tnameparams
[
2
].
trim
())
console
.
log
(
taskName
,
postMinute
,
"xxxxxxxxxxxxxxxxxxxxxxx"
)
if
(
mtype
==
"i"
)
{
//每几分钟执行一次
//如果流失的时间大于循环调度时间,则报异常到丁丁
console
.
log
(
taskName
,
postMinute
,
"xxxxxxxxxxxxxxxxxxxxxxx"
)
if
(
postMinute
>
pvalue
)
{
//如果流失的时间大于循环调度时间,则报异常到丁丁
this
.
sendDing
(
tname
+
"可能失联啦...请检查"
)
if
(
postMinute
>
pvalue
)
{
}
else
{
this
.
sendDing
(
tname
+
"可能失联啦...请检查"
)
if
(
tname
==
this
.
serviceName
)
{
}
else
{
this
.
sendDing
(
tname
+
"监控精灵依然在线,请放心...."
)
if
(
tname
==
this
.
serviceName
)
{
this
.
sendDing
(
tname
+
"监控精灵依然在线,请放心...."
)
}
}
}
}
}
}
if
(
mtype
==
"a"
)
{
//
if
(
mtype
==
"a"
)
{
//
let
onedaym
=
24
*
60
let
onedaym
=
24
*
60
if
(
postMinute
>
onedaym
)
{
if
(
postMinute
>
onedaym
)
{
this
.
sendDing
(
tname
+
"可能失联啦...请检查"
)
this
.
sendDing
(
tname
+
"可能失联啦...请检查"
)
}
}
}
}
else
{
this
.
sendDing
(
taskName
+
":任务名不符合监控格式"
)
}
}
}
}
async
subBeforeTask
(
params
)
{
async
subBeforeTask
(
params
)
{
console
.
log
(
"前置操作......"
,
this
.
serviceName
);
console
.
log
(
"前置操作......"
,
this
.
serviceName
);
...
...
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