kibana-123
Version:
Kibana is an open source (Apache Licensed), browser based analytics and search dashboard for Elasticsearch. Kibana is a snap to setup and start using. Kibana strives to be easy to get started with, while also being flexible and powerful, just like Elastic
46 lines (38 loc) • 1.07 kB
JavaScript
import { fromNode } from 'bluebird';
import { get, once } from 'lodash';
module.exports = (kbnServer, server, config) => {
server.route({
path: '/bundles/{path*}',
method: 'GET',
handler: {
proxy: {
host: config.get('optimize.lazyHost'),
port: config.get('optimize.lazyPort'),
passThrough: true,
xforward: true
}
},
config: {auth: false}
});
return fromNode(cb => {
let timeout = setTimeout(() => {
cb(new Error('Server timedout waiting for the optimizer to become ready'));
}, config.get('optimize.lazyProxyTimeout'));
let waiting = once(() => {
server.log(['info', 'optimize'], 'Waiting for optimizer completion');
});
if (!process.connected) return;
process.send(['WORKER_BROADCAST', { optimizeReady: '?' }]);
process.on('message', (msg) => {
switch (get(msg, 'optimizeReady')) {
case true:
clearTimeout(timeout);
cb();
break;
case false:
waiting();
break;
}
});
});
};