mirror of
https://github.com/ansible/awx.git
synced 2026-01-15 03:40:42 -03:30
fix race condition with status socket
This commit is contained in:
parent
f59b3ad886
commit
69220e94de
@ -1,5 +1,5 @@
|
||||
export default ['jobData', 'jobDataOptions', 'jobLabels', 'jobFinished', 'count', '$scope', 'ParseTypeChange', 'ParseVariableString', 'jobResultsService', 'eventQueue', '$compile', '$log', 'Dataset', '$q', 'Rest', '$state', 'QuerySet', '$rootScope', 'moment', '$stateParams', 'i18n', 'fieldChoices', 'fieldLabels', 'workflowResultsService',
|
||||
function(jobData, jobDataOptions, jobLabels, jobFinished, count, $scope, ParseTypeChange, ParseVariableString, jobResultsService, eventQueue, $compile, $log, Dataset, $q, Rest, $state, QuerySet, $rootScope, moment, $stateParams, i18n, fieldChoices, fieldLabels, workflowResultsService) {
|
||||
export default ['jobData', 'jobDataOptions', 'jobLabels', 'jobFinished', 'count', '$scope', 'ParseTypeChange', 'ParseVariableString', 'jobResultsService', 'eventQueue', '$compile', '$log', 'Dataset', '$q', 'Rest', '$state', 'QuerySet', '$rootScope', 'moment', '$stateParams', 'i18n', 'fieldChoices', 'fieldLabels', 'workflowResultsService', 'statusSocket',
|
||||
function(jobData, jobDataOptions, jobLabels, jobFinished, count, $scope, ParseTypeChange, ParseVariableString, jobResultsService, eventQueue, $compile, $log, Dataset, $q, Rest, $state, QuerySet, $rootScope, moment, $stateParams, i18n, fieldChoices, fieldLabels, workflowResultsService, statusSocket) {
|
||||
var toDestroy = [];
|
||||
var cancelRequests = false;
|
||||
var runTimeElapsedTimer = null;
|
||||
@ -664,6 +664,14 @@ function(jobData, jobDataOptions, jobLabels, jobFinished, count, $scope, ParseTy
|
||||
});
|
||||
}));
|
||||
|
||||
// get previously set up socket messages from resolve
|
||||
if (statusSocket[0].job_status) {
|
||||
$scope.job_status = statusSocket[0].job_status;
|
||||
}
|
||||
if ($scope.job_status === "running") {
|
||||
runTimeElapsedTimer = workflowResultsService.createOneSecondTimer(moment(), updateJobElapsedTimer);
|
||||
}
|
||||
|
||||
// Processing of job-status messages from the websocket
|
||||
toDestroy.push($scope.$on(`ws-jobs`, function(e, data) {
|
||||
if (parseInt(data.unified_job_id, 10) ===
|
||||
@ -671,7 +679,9 @@ function(jobData, jobDataOptions, jobLabels, jobFinished, count, $scope, ParseTy
|
||||
// controller is defined, so set the job_status
|
||||
$scope.job_status = data.status;
|
||||
if (data.status === "running") {
|
||||
runTimeElapsedTimer = workflowResultsService.createOneSecondTimer(moment(), updateJobElapsedTimer);
|
||||
if (!runTimeElapsedTimer) {
|
||||
runTimeElapsedTimer = workflowResultsService.createOneSecondTimer(moment(), updateJobElapsedTimer);
|
||||
}
|
||||
} else if (data.status === "successful" ||
|
||||
data.status === "failed" ||
|
||||
data.status === "error" ||
|
||||
@ -699,7 +709,12 @@ function(jobData, jobDataOptions, jobLabels, jobFinished, count, $scope, ParseTy
|
||||
}
|
||||
}));
|
||||
|
||||
statusSocket[1]();
|
||||
|
||||
$scope.$on('$destroy', function(){
|
||||
if (statusSocket[1]) {
|
||||
statusSocket[1]();
|
||||
}
|
||||
$( ".JobResultsStdOut-aLineOfStdOut" ).remove();
|
||||
cancelRequests = true;
|
||||
eventQueue.initialize();
|
||||
|
||||
@ -36,6 +36,16 @@ export default {
|
||||
}
|
||||
},
|
||||
resolve: {
|
||||
statusSocket: ['$rootScope', '$stateParams', function($rootScope, $stateParams) {
|
||||
var preScope = {};
|
||||
var eventOn = $rootScope.$on(`ws-jobs`, function(e, data) {
|
||||
if (parseInt(data.unified_job_id, 10) ===
|
||||
parseInt($stateParams.id,10)) {
|
||||
preScope.job_status = data.status;
|
||||
}
|
||||
});
|
||||
return [preScope, eventOn];
|
||||
}],
|
||||
// the GET for the particular job
|
||||
jobData: ['Rest', 'GetBasePath', '$stateParams', '$q', '$state', 'Alert', 'jobResultsService', function(Rest, GetBasePath, $stateParams, $q, $state, Alert, jobResultsService) {
|
||||
return jobResultsService.getJobData($stateParams.id);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user