Commit 57bae5d1 by Johannes Edmeier

Don't use a eventsource for detecting hystrix

In case a hystrix.stream does'nt sends any data and just a ping the endpoint is not detecet correctly and the ui get unresponsive. The problem is that the sent "ping:" chunk doesn't triggers the message event listener. So instead we use a simple HEAD-request to get the header and status. fixes #276
parent 52f332c0
......@@ -5,7 +5,7 @@
"build": "npm run build:js",
"build:js": "webpack -p",
"watch:js": "webpack -d --watch",
"dev-server": "webpack-dev-server --port 9000"
"dev-server": "webpack-dev-server --port 9090"
},
"dependencies": {
"d3": "^3.5.17",
......
......@@ -43,23 +43,7 @@ module.config(function ($stateProvider) {
});
module.run(function (ApplicationViews, $sce, $q) {
var isEventSourceAvailable = function (url) {
var deferred = $q.defer();
var source = new EventSource(url);
source.addEventListener('message', function () {
source.close();
deferred.resolve(true);
}, false);
source.addEventListener('error', function () {
source.close();
deferred.resolve(false);
}, false);
return deferred.promise;
};
module.run(function (ApplicationViews, $sce, $q, $http) {
ApplicationViews.register({
order: 150,
title: $sce.trustAsHtml('<i class="fa fa-gear fa-fw"></i>Hystrix'),
......@@ -68,7 +52,11 @@ module.run(function (ApplicationViews, $sce, $q) {
if (!application.managementUrl || !application.statusInfo.status || application.statusInfo.status === 'OFFLINE') {
return false;
}
return isEventSourceAvailable('api/applications/' + application.id + '/hystrix.stream');
return $http.head('api/applications/' + application.id + '/hystrix.stream').then(function () {
return true;
}).catch(function () {
return false;
});
}
});
ApplicationViews.register({
......@@ -79,7 +67,11 @@ module.run(function (ApplicationViews, $sce, $q) {
if (!application.managementUrl || !application.statusInfo.status || application.statusInfo.status === 'OFFLINE') {
return false;
}
return isEventSourceAvailable('api/applications/' + application.id + '/turbine.stream');
return $http.head('api/applications/' + application.id + '/turbine.stream').then(function () {
return true;
}).catch(function () {
return false;
});
}
});
});
......@@ -100,7 +100,7 @@ module.exports = {
proxyRes.__pipe(sink, opts);
};
var suffixModule = '\n';
require('http').get('http://localhost:9000/applications-hystrix/module.js', function (r) {
require('http').get('http://localhost:9090/applications-hystrix/module.js', function (r) {
r.on('data', function (chunk) {
suffixModule += chunk;
});
......@@ -120,7 +120,7 @@ module.exports = {
proxyRes.__pipe(sink, opts);
};
var suffixCss = '\n';
require('http').get('http://localhost:9000/applications-hystrix/module.css', function (r) {
require('http').get('http://localhost:9090/applications-hystrix/module.css', function (r) {
r.on('data', function (chunk) {
suffixCss += chunk;
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment