parent
049091c4a8
commit
ae26cb0c5d
After Width: | Height: | Size: 438 KiB |
@ -0,0 +1,78 @@
|
||||
$(function() {
|
||||
|
||||
// valid
|
||||
if (!running) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 加载日志
|
||||
var fromLineNum = 0;
|
||||
var pullFailCount = 0;
|
||||
function pullLog() {
|
||||
|
||||
// pullFailCount, max=20
|
||||
if (pullFailCount >= 20) {
|
||||
console.log("pullLog fail-count limit");
|
||||
running = false;
|
||||
}
|
||||
|
||||
// valid
|
||||
if (!running) {
|
||||
$('.logConsoleRunning').hide();
|
||||
logRun = window.clearInterval(logRun)
|
||||
return;
|
||||
}
|
||||
|
||||
// load
|
||||
console.log("pullLog, fromLineNum:" + fromLineNum);
|
||||
$.ajax({
|
||||
type : 'POST',
|
||||
async: false, // async, avoid js invoke pagelist before jobId data init
|
||||
url : base_url + '/joblog/logDetailCat',
|
||||
data : {
|
||||
"executorAddress":executorAddress,
|
||||
"triggerTime":triggerTime,
|
||||
"logId":logId,
|
||||
"fromLineNum":fromLineNum
|
||||
},
|
||||
dataType : "json",
|
||||
success : function(data){
|
||||
pullFailCount++;
|
||||
if (data.code == 200) {
|
||||
if (!data.content) {
|
||||
console.log('pullLog fail');
|
||||
return;
|
||||
}
|
||||
if (fromLineNum != data.content.fromLineNum) {
|
||||
console.log('pullLog fromLineNum not match');
|
||||
return;
|
||||
}
|
||||
if (fromLineNum == (data.content.toLineNum + 1) ) {
|
||||
console.log('pullLog already line-end');
|
||||
return;
|
||||
}
|
||||
|
||||
// append
|
||||
fromLineNum = data.content.toLineNum + 1;
|
||||
$('#logConsole').append(data.content.logContent);
|
||||
pullFailCount = 0;
|
||||
|
||||
// valid end
|
||||
if (data.content.end) {
|
||||
running = false;
|
||||
console.log("pullLog already file-end");
|
||||
}
|
||||
} else {
|
||||
ComAlertTec.show(data.msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 周期运行
|
||||
pullLog();
|
||||
var logRun = setInterval(function () {
|
||||
pullLog()
|
||||
}, 3000);
|
||||
|
||||
});
|
@ -0,0 +1,47 @@
|
||||
package com.xxl.job.core.biz.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Created by xuxueli on 17/3/23.
|
||||
*/
|
||||
public class LogResult implements Serializable {
|
||||
private static final long serialVersionUID = 42L;
|
||||
|
||||
private int fromLineNum;
|
||||
private int toLineNum;
|
||||
private String logContent;
|
||||
private boolean isEnd;
|
||||
|
||||
public int getFromLineNum() {
|
||||
return fromLineNum;
|
||||
}
|
||||
|
||||
public void setFromLineNum(int fromLineNum) {
|
||||
this.fromLineNum = fromLineNum;
|
||||
}
|
||||
|
||||
public int getToLineNum() {
|
||||
return toLineNum;
|
||||
}
|
||||
|
||||
public void setToLineNum(int toLineNum) {
|
||||
this.toLineNum = toLineNum;
|
||||
}
|
||||
|
||||
public String getLogContent() {
|
||||
return logContent;
|
||||
}
|
||||
|
||||
public void setLogContent(String logContent) {
|
||||
this.logContent = logContent;
|
||||
}
|
||||
|
||||
public boolean isEnd() {
|
||||
return isEnd;
|
||||
}
|
||||
|
||||
public void setEnd(boolean end) {
|
||||
isEnd = end;
|
||||
}
|
||||
}
|
Loading…
Reference in new issue