|
@@ -1,78 +1,88 @@
|
1
|
1
|
$(function() {
|
2
|
2
|
|
3
|
|
- // valid
|
4
|
|
- if (!running) {
|
5
|
|
- return;
|
6
|
|
- }
|
|
3
|
+ // trigger fail, end
|
|
4
|
+ if (triggerCode != 200) {
|
|
5
|
+ $('#logConsoleRunning').hide();
|
|
6
|
+ $('#logConsole').append('<span style="color: red;">任务发起调度失败,无法查看执行日志</span>');
|
|
7
|
+ return;
|
|
8
|
+ }
|
7
|
9
|
|
8
|
|
- // 加载日志
|
9
|
|
- var fromLineNum = 0;
|
10
|
|
- var pullFailCount = 0;
|
11
|
|
- function pullLog() {
|
|
10
|
+ // pull log
|
|
11
|
+ var fromLineNum = 0;
|
|
12
|
+ var pullFailCount = 0;
|
|
13
|
+ function pullLog() {
|
|
14
|
+ // pullFailCount, max=20
|
|
15
|
+ if (pullFailCount++ > 20) {
|
|
16
|
+ logRunStop('<span style="color: red;">终止请求Rolling日志,请求失败次数超上限,可刷新页面重新加载日志</span>');
|
|
17
|
+ return;
|
|
18
|
+ }
|
12
|
19
|
|
13
|
|
- // pullFailCount, max=20
|
14
|
|
- if (pullFailCount >= 20) {
|
15
|
|
- console.log("pullLog fail-count limit");
|
16
|
|
- running = false;
|
17
|
|
- }
|
|
20
|
+ // load
|
|
21
|
+ console.log("pullLog, fromLineNum:" + fromLineNum);
|
18
|
22
|
|
19
|
|
- // valid
|
20
|
|
- if (!running) {
|
21
|
|
- $('.logConsoleRunning').hide();
|
22
|
|
- logRun = window.clearInterval(logRun)
|
23
|
|
- return;
|
24
|
|
- }
|
|
23
|
+ $.ajax({
|
|
24
|
+ type : 'POST',
|
|
25
|
+ async: false, // sync, make log ordered
|
|
26
|
+ url : base_url + '/joblog/logDetailCat',
|
|
27
|
+ data : {
|
|
28
|
+ "executorAddress":executorAddress,
|
|
29
|
+ "triggerTime":triggerTime,
|
|
30
|
+ "logId":logId,
|
|
31
|
+ "fromLineNum":fromLineNum
|
|
32
|
+ },
|
|
33
|
+ dataType : "json",
|
|
34
|
+ success : function(data){
|
25
|
35
|
|
26
|
|
- // load
|
27
|
|
- console.log("pullLog, fromLineNum:" + fromLineNum);
|
28
|
|
- $.ajax({
|
29
|
|
- type : 'POST',
|
30
|
|
- async: false, // async, avoid js invoke pagelist before jobId data init
|
31
|
|
- url : base_url + '/joblog/logDetailCat',
|
32
|
|
- data : {
|
33
|
|
- "executorAddress":executorAddress,
|
34
|
|
- "triggerTime":triggerTime,
|
35
|
|
- "logId":logId,
|
36
|
|
- "fromLineNum":fromLineNum
|
37
|
|
- },
|
38
|
|
- dataType : "json",
|
39
|
|
- success : function(data){
|
40
|
|
- pullFailCount++;
|
41
|
|
- if (data.code == 200) {
|
42
|
|
- if (!data.content) {
|
43
|
|
- console.log('pullLog fail');
|
44
|
|
- return;
|
45
|
|
- }
|
46
|
|
- if (fromLineNum != data.content.fromLineNum) {
|
47
|
|
- console.log('pullLog fromLineNum not match');
|
48
|
|
- return;
|
49
|
|
- }
|
50
|
|
- if (fromLineNum == (data.content.toLineNum + 1) ) {
|
51
|
|
- console.log('pullLog already line-end');
|
52
|
|
- return;
|
53
|
|
- }
|
|
36
|
+ if (data.code == 200) {
|
|
37
|
+ if (!data.content) {
|
|
38
|
+ console.log('pullLog fail');
|
|
39
|
+ return;
|
|
40
|
+ }
|
|
41
|
+ if (fromLineNum != data.content.fromLineNum) {
|
|
42
|
+ console.log('pullLog fromLineNum not match');
|
|
43
|
+ return;
|
|
44
|
+ }
|
|
45
|
+ if (fromLineNum == (data.content.toLineNum + 1) ) {
|
|
46
|
+ console.log('pullLog already line-end');
|
|
47
|
+ return;
|
|
48
|
+ }
|
54
|
49
|
|
55
|
|
- // append
|
56
|
|
- fromLineNum = data.content.toLineNum + 1;
|
57
|
|
- $('#logConsole').append(data.content.logContent);
|
58
|
|
- pullFailCount = 0;
|
|
50
|
+ // append
|
|
51
|
+ fromLineNum = data.content.toLineNum + 1;
|
|
52
|
+ $('#logConsole').append(data.content.logContent);
|
|
53
|
+ pullFailCount = 0;
|
|
54
|
+
|
|
55
|
+ // valid end
|
|
56
|
+ if (data.content.end) {
|
|
57
|
+ logRunStop('<span style="color: green;">[Rolling Log Finish]</span>');
|
|
58
|
+ return;
|
|
59
|
+ }
|
|
60
|
+ } else {
|
|
61
|
+ console.log('pullLog fail:'+data.msg);
|
|
62
|
+ }
|
|
63
|
+ }
|
|
64
|
+ });
|
|
65
|
+ }
|
|
66
|
+
|
|
67
|
+ // pull first page
|
|
68
|
+ pullLog();
|
|
69
|
+
|
|
70
|
+ // handler already callback, end
|
|
71
|
+ if (handleCode > 0) {
|
|
72
|
+ logRunStop('<span style="color: green;">[Log Finish]</span>');
|
|
73
|
+ return;
|
|
74
|
+ }
|
|
75
|
+
|
|
76
|
+ // round until end
|
|
77
|
+ var logRun = setInterval(function () {
|
|
78
|
+ pullLog()
|
|
79
|
+ }, 3000);
|
|
80
|
+ function logRunStop(content){
|
|
81
|
+ $('#logConsoleRunning').hide();
|
|
82
|
+ logRun = window.clearInterval(logRun);
|
|
83
|
+ $('#logConsole').append(content);
|
|
84
|
+ }
|
59
|
85
|
|
60
|
|
- // valid end
|
61
|
|
- if (data.content.end) {
|
62
|
|
- running = false;
|
63
|
|
- console.log("pullLog already file-end");
|
64
|
|
- }
|
65
|
|
- } else {
|
66
|
|
- ComAlertTec.show(data.msg);
|
67
|
|
- }
|
68
|
|
- }
|
69
|
|
- });
|
70
|
|
- }
|
71
|
86
|
|
72
|
|
- // 周期运行
|
73
|
|
- pullLog();
|
74
|
|
- var logRun = setInterval(function () {
|
75
|
|
- pullLog()
|
76
|
|
- }, 3000);
|
77
|
87
|
|
78
|
88
|
});
|