瀏覽代碼

rolling日志交互

xueli.xue 8 年之前
父節點
當前提交
d794fd0102

+ 9 - 0
xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobLogController.java 查看文件

118
 		try {
118
 		try {
119
 			ExecutorBiz executorBiz = (ExecutorBiz) new NetComClientProxy(ExecutorBiz.class, executorAddress).getObject();
119
 			ExecutorBiz executorBiz = (ExecutorBiz) new NetComClientProxy(ExecutorBiz.class, executorAddress).getObject();
120
 			ReturnT<LogResult> logResult = executorBiz.log(triggerTime, logId, fromLineNum);
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
 			return logResult;
130
 			return logResult;
122
 		} catch (Exception e) {
131
 		} catch (Exception e) {
123
 			e.printStackTrace();
132
 			e.printStackTrace();

+ 9 - 21
xxl-job-admin/src/main/webapp/WEB-INF/template/joblog/logdetail.ftl 查看文件

4
     <title>任务调度中心</title>
4
     <title>任务调度中心</title>
5
 <#import "/common/common.macro.ftl" as netCommon>
5
 <#import "/common/common.macro.ftl" as netCommon>
6
 <@netCommon.commonStyle />
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
 </head>
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
     <header class="main-header">
12
     <header class="main-header">
29
         <nav class="navbar navbar-static-top">
13
         <nav class="navbar navbar-static-top">
59
         </nav>
43
         </nav>
60
     </header>
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
             <div style="margin-top: 50px;" ></div>
50
             <div style="margin-top: 50px;" ></div>
66
         </pre>
51
         </pre>
67
     </div>
52
     </div>
68
 
53
 
69
 </div>
54
 </div>
70
 
55
 
56
+
57
+
58
+
71
 <@netCommon.commonScript />
59
 <@netCommon.commonScript />
72
 <script>
60
 <script>
73
     // 参数
61
     // 参数

+ 11 - 8
xxl-job-admin/src/main/webapp/static/js/logdetail.index.1.js 查看文件

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