Merge pull request #4907 from BigFunger/server-use-bundle-cache

Server use bundle cache
This commit is contained in:
Rashid Khan 2015-09-14 15:59:41 -07:00
commit 8cc62c857e
6 changed files with 53 additions and 4 deletions

View file

@ -34,6 +34,11 @@ module.exports = function (program) {
.option('-q, --quiet', 'Disable all process messaging except errors')
.option('-s, --silent', 'Disable all process messaging')
.option('-u, --url <url>', 'Specify download url')
.option(
'-c, --config <path>',
'Path to the config file',
fromRoot('config/kibana.yml')
)
.option(
'-t, --timeout <duration>',
'Length of time before failing; 0 for never fail',

View file

@ -1,5 +1,10 @@
let _ = require('lodash');
var utils = require('requirefrom')('src/utils');
var fromRoot = utils('fromRoot');
var pluginDownloader = require('./pluginDownloader');
var pluginCleaner = require('./pluginCleaner');
var KbnServer = require('../../server/KbnServer');
var readYamlConfig = require('../serve/readYamlConfig');
var fs = require('fs');
module.exports = {
@ -25,7 +30,36 @@ function install(settings, logger) {
.then(function () {
return downloader.download();
})
.then(function (curious) {
.then(async function() {
logger.log('Optimizing and caching browser bundles...');
let serverConfig = _.merge(
readYamlConfig(settings.config),
{
env: 'production',
logging: {
silent: settings.silent,
quiet: !settings.silent,
verbose: false
},
optimize: {
useBundleCache: false
},
server: {
autoListen: false
},
plugins: {
initialize: false,
scanDirs: [settings.pluginDir, fromRoot('src/plugins')],
paths: [settings.workingPath]
}
}
);
let kbnServer = new KbnServer(serverConfig);
await kbnServer.ready();
await kbnServer.close();
})
.then(function () {
fs.renameSync(settings.workingPath, settings.pluginPath);
logger.log('Plugin installation complete');
})

View file

@ -54,6 +54,10 @@ module.exports = function (options) {
settings.urls.push(options.url);
}
if (options.config) {
settings.config = options.config;
}
if (options.install) {
settings.action = 'install';
parts = options.install.split('/');

View file

@ -32,7 +32,10 @@ module.exports = function (program) {
.description('Run the kibana server')
.collectUnknownOptions()
.option('-e, --elasticsearch <uri>', 'Elasticsearch instance')
.option('-c, --config <path>', 'Path to the config file')
.option(
'-c, --config <path>',
'Path to the config file',
fromRoot('config/kibana.yml'))
.option('-p, --port <port>', 'The port to bind to', parseInt)
.option('-q, --quiet', 'Prevent all logging except errors')
.option('-Q, --silent', 'Prevent all logging')
@ -76,7 +79,7 @@ module.exports = function (program) {
let readYamlConfig = require('./readYamlConfig');
let KbnServer = src('server/KbnServer');
let settings = readYamlConfig(opts.config || fromRoot('config/kibana.yml'));
let settings = readYamlConfig(opts.config);
if (opts.dev) {
try { _.merge(settings, readYamlConfig(fromRoot('config/kibana.dev.yml'))); }

View file

@ -19,7 +19,9 @@ module.exports = async (kbnServer, server, config) => {
await bundles.writeEntryFiles();
// in prod, only bundle what looks invalid or missing
if (config.get('env.prod')) bundles = await kbnServer.bundles.getInvalidBundles();
if (config.get('optimize.useBundleCache')) {
bundles = await bundles.getInvalidBundles();
}
// we might not have any work to do
if (!bundles.getIds().length) {

View file

@ -87,6 +87,7 @@ module.exports = Joi.object({
lazyHost: Joi.string().hostname().default('localhost'),
lazyPrebuild: Joi.boolean().default(false),
lazyProxyTimeout: Joi.number().default(5 * 60000),
useBundleCache: Joi.boolean().default(Joi.ref('$prod')),
unsafeCache: Joi
.alternatives()
.try(