Job detail

Monitor socket connection and attempt to restart when status returns 'error' or continuously returns 'connecting'.
This commit is contained in:
Chris Houseknecht
2014-07-25 10:24:15 -04:00
parent 9af5cc3d6d
commit f0cb84d973

View File

@@ -19,7 +19,9 @@ function JobDetailController ($location, $rootScope, $scope, $compile, $routePar
api_complete = false, api_complete = false,
refresh_count = 0, refresh_count = 0,
lastEventId = 0, lastEventId = 0,
verbosity_options, job_type_options; verbosity_options,
job_type_options,
checkCount = 0;
scope.plays = []; scope.plays = [];
scope.hosts = []; scope.hosts = [];
@@ -77,20 +79,36 @@ function JobDetailController ($location, $rootScope, $scope, $compile, $routePar
"<p><i class=\"fa fa-circle failed-hosts-color\"></i> Failed</p>\n" + "<p><i class=\"fa fa-circle failed-hosts-color\"></i> Failed</p>\n" +
"<div class=\"popover-footer\"><span class=\"key\">esc</span> or click to close</div>\n"; "<div class=\"popover-footer\"><span class=\"key\">esc</span> or click to close</div>\n";
function openSocket() {
event_socket = Socket({ event_socket = Socket({
scope: scope, scope: scope,
endpoint: "job_events" endpoint: "job_events"
}); });
event_socket.init(); event_socket.init();
event_socket.on("job_events-" + job_id, function(data) { event_socket.on("job_events-" + job_id, function(data) {
if (api_complete && data.id > lastEventId) { if (api_complete && data.id > lastEventId) {
data.event = data.event_name; data.event = data.event_name;
DigestEvent({ scope: scope, event: data }); DigestEvent({ scope: scope, event: data });
} }
}); });
}
openSocket();
$rootScope.checkSocketConnectionInterval = setInterval(function() {
if (event_socket.checkStatus() === 'error' || checkCount > 2) {
// there's an error or we're stuck in a 'connecting' state. attempt to reconnect
$log.debug('job detail page: initializing and restarting socket connections');
event_socket = null;
openSocket();
checkCount = 0;
}
else if (event_socket.checkStatus() === 'connecting') {
checkCount++;
}
else {
checkCount = 0;
}
}, 3000);
if ($rootScope.removeJobStatusChange) { if ($rootScope.removeJobStatusChange) {
$rootScope.removeJobStatusChange(); $rootScope.removeJobStatusChange();