Bladeren bron

rolling日志交互

xueli.xue 8 jaren geleden
bovenliggende
commit
d794fd0102

+ 9 - 0
xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobLogController.java Bestand weergeven

@@ -118,6 +118,15 @@ public class JobLogController {
118 118
 		try {
119 119
 			ExecutorBiz executorBiz = (ExecutorBiz) new NetComClientProxy(ExecutorBiz.class, executorAddress).getObject();
120 120
 			ReturnT<LogResult> logResult = executorBiz.log(triggerTime, logId, fromLineNum);
121
+
122
+			// is end
123
+			if (logResult.getContent()!=null && logResult.getContent().getFromLineNum() > logResult.getContent().getToLineNum()) {
124
+				XxlJobLog jobLog = xxlJobLogDao.load(logId);
125
+				if (jobLog.getHandleCode() > 0) {
126
+					logResult.getContent().setEnd(true);
127
+				}
128
+			}
129
+
121 130
 			return logResult;
122 131
 		} catch (Exception e) {
123 132
 			e.printStackTrace();

+ 9 - 21
xxl-job-admin/src/main/webapp/WEB-INF/template/joblog/logdetail.ftl Bestand weergeven

@@ -4,26 +4,10 @@
4 4
     <title>任务调度中心</title>
5 5
 <#import "/common/common.macro.ftl" as netCommon>
6 6
 <@netCommon.commonStyle />
7
-    <style type="text/css">
8
-        .logConsolePre {
9
-            font-size:12px;
10
-            width: 100%;
11
-            height: 100%;
12
-            /*bottom: 0;
13
-            top: 0px;*/
14
-            position: absolute;
15
-            /*color:white;background-color:black*/
16
-        }
17
-        #logConsoleRunning {
18
-            font-size: 20px;
19
-            margin-top: 7px;
20
-            float: left;
21
-        }
22
-    </style>
23 7
 </head>
24
-<body class="skin-blue fixed layout-top-nav">
8
+<body class="hold-transition skin-blue layout-top-nav">
25 9
 
26
-<div class="wrapper">
10
+<div class2="wrapper">
27 11
 
28 12
     <header class="main-header">
29 13
         <nav class="navbar navbar-static-top">
@@ -59,15 +43,19 @@
59 43
         </nav>
60 44
     </header>
61 45
 
62
-    <div class="content-wrapper" >
63
-        <pre class="logConsolePre"><div id="logConsole"></div>
64
-            <li class="fa fa-refresh fa-spin" id="logConsoleRunning" ></li>
46
+    <div>
47
+        <pre>
48
+            <div id="logConsole"></div>
49
+            <li class="fa fa-refresh fa-spin" style="font-size: 20px;float: left;" id="logConsoleRunning" ></li>
65 50
             <div style="margin-top: 50px;" ></div>
66 51
         </pre>
67 52
     </div>
68 53
 
69 54
 </div>
70 55
 
56
+
57
+
58
+
71 59
 <@netCommon.commonScript />
72 60
 <script>
73 61
     // 参数

+ 11 - 8
xxl-job-admin/src/main/webapp/static/js/logdetail.index.1.js Bestand weergeven

@@ -8,7 +8,7 @@ $(function() {
8 8
     }
9 9
 
10 10
     // pull log
11
-    var fromLineNum = 0;
11
+    var fromLineNum = 0;    // [from, to]
12 12
     var pullFailCount = 0;
13 13
     function pullLog() {
14 14
         // pullFailCount, max=20
@@ -42,8 +42,13 @@ $(function() {
42 42
                         console.log('pullLog fromLineNum not match');
43 43
                         return;
44 44
                     }
45
-                    if (fromLineNum == (data.content.toLineNum + 1) ) {
45
+                    if (fromLineNum > data.content.toLineNum ) {
46 46
                         console.log('pullLog already line-end');
47
+                        // valid end
48
+                        if (data.content.end) {
49
+                            logRunStop('<span style="color: green;">[Rolling Log Finish]</span>');
50
+                            return;
51
+                        }
47 52
                         return;
48 53
                     }
49 54
 
@@ -52,11 +57,9 @@ $(function() {
52 57
                     $('#logConsole').append(data.content.logContent);
53 58
                     pullFailCount = 0;
54 59
 
55
-                    // valid end
56
-                    if (data.content.end) {
57
-                        logRunStop('<span style="color: green;">[Rolling Log Finish]</span>');
58
-                        return;
59
-                    }
60
+                    // scroll to bottom
61
+                    scrollTo(0, document.body.scrollHeight);
62
+
60 63
                 } else {
61 64
                     console.log('pullLog fail:'+data.msg);
62 65
                 }
@@ -69,7 +72,7 @@ $(function() {
69 72
 
70 73
     // handler already callback, end
71 74
     if (handleCode > 0) {
72
-        logRunStop('<span style="color: green;">[Log Finish]</span>');
75
+        logRunStop('<span style="color: green;">[Load Log Finish]</span>');
73 76
         return;
74 77
     }
75 78