mirror of
https://github.com/ansible/awx.git
synced 2026-05-13 12:27:37 -02:30
rudimentary buffer of incoming stdout events
This commit is contained in:
@@ -571,10 +571,24 @@ function(jobData, jobDataOptions, jobLabels, jobFinished, count, $scope, ParseTy
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
var buffer = [];
|
||||||
|
|
||||||
|
var processBuffer = function() {
|
||||||
|
buffer.forEach((event, i) => {
|
||||||
|
processEvent(event);
|
||||||
|
buffer.splice(i, 1);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
var bufferInterval = undefined;
|
||||||
|
|
||||||
// Processing of job_events messages from the websocket
|
// Processing of job_events messages from the websocket
|
||||||
toDestroy.push($scope.$on(`ws-job_events-${$scope.job.id}`, function(e, data) {
|
toDestroy.push($scope.$on(`ws-job_events-${$scope.job.id}`, function(e, data) {
|
||||||
|
if (bufferInterval === undefined) {
|
||||||
|
bufferInterval = setInterval(function(){
|
||||||
|
processBuffer();
|
||||||
|
}, 500);
|
||||||
|
}
|
||||||
|
|
||||||
// use the lowest counter coming over the socket to retrigger pull data
|
// use the lowest counter coming over the socket to retrigger pull data
|
||||||
// to only be for stuff lower than that id
|
// to only be for stuff lower than that id
|
||||||
@@ -601,6 +615,7 @@ function(jobData, jobDataOptions, jobLabels, jobFinished, count, $scope, ParseTy
|
|||||||
} else if (data.event_name === "playbook_on_task_start") {
|
} else if (data.event_name === "playbook_on_task_start") {
|
||||||
$scope.taskCount++;
|
$scope.taskCount++;
|
||||||
}
|
}
|
||||||
|
buffer.push(data);
|
||||||
processEvent(data);
|
processEvent(data);
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
@@ -616,6 +631,9 @@ function(jobData, jobDataOptions, jobLabels, jobFinished, count, $scope, ParseTy
|
|||||||
data.status === "error" ||
|
data.status === "error" ||
|
||||||
data.status === "canceled") {
|
data.status === "canceled") {
|
||||||
clearInterval(elapsedInterval);
|
clearInterval(elapsedInterval);
|
||||||
|
if (bufferInterval !== undefined) {
|
||||||
|
clearInterval(bufferInterval);
|
||||||
|
}
|
||||||
// When the fob is finished retrieve the job data to
|
// When the fob is finished retrieve the job data to
|
||||||
// correct anything that was out of sync from the job run
|
// correct anything that was out of sync from the job run
|
||||||
jobResultsService.getJobData($scope.job.id).then(function(data){
|
jobResultsService.getJobData($scope.job.id).then(function(data){
|
||||||
@@ -647,6 +665,9 @@ function(jobData, jobDataOptions, jobLabels, jobFinished, count, $scope, ParseTy
|
|||||||
});
|
});
|
||||||
$scope.events = {};
|
$scope.events = {};
|
||||||
clearInterval(elapsedInterval);
|
clearInterval(elapsedInterval);
|
||||||
|
if (bufferInterval !== undefined) {
|
||||||
|
clearInterval(bufferInterval);
|
||||||
|
}
|
||||||
toDestroy.forEach(closureFunc => closureFunc());
|
toDestroy.forEach(closureFunc => closureFunc());
|
||||||
});
|
});
|
||||||
}];
|
}];
|
||||||
|
|||||||
Reference in New Issue
Block a user