Skip to content

Commit

Permalink
Add optimize flags
Browse files Browse the repository at this point in the history
  • Loading branch information
jbudz committed Jul 5, 2018
1 parent 3bae675 commit 1302cc2
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
16 changes: 15 additions & 1 deletion src/cli/serve/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ function readServerSettings(opts, extraCliOptions) {
if (opts.verbose) set('logging.verbose', true);
if (opts.logFile) set('logging.dest', opts.logFile);

if (opts.optimize) {
set('server.autoListen', false);
set('plugins.initialize', false);
}

set('plugins.scanDirs', _.compact([].concat(
get('plugins.scanDirs'),
opts.pluginDir
Expand Down Expand Up @@ -171,7 +176,9 @@ export default function (program) {
pluginPathCollector,
[]
)
.option('--plugins <path>', 'an alias for --plugin-dir', pluginDirCollector);
.option('--plugins <path>', 'an alias for --plugin-dir', pluginDirCollector)
.option('--optimize', 'Optimize and then stop the server');


if (!!startRepl) {
command.option('--repl', 'Run the server with a REPL prompt and access to the server object');
Expand Down Expand Up @@ -251,8 +258,15 @@ export default function (program) {
kbnServer.server.log(['info', 'config'], 'Reloaded logging configuration due to SIGHUP.');
});

if (opts.optimize) {
kbnServer.server.log(['info'], 'Optimization done.');
await kbnServer.close();
process.exit();
}

return kbnServer;
});

}

function shouldStartRepl(opts) {
Expand Down
1 change: 1 addition & 0 deletions src/cli_plugin/install/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export default function pluginInstall(program) {
.command('install <plugin/url>')
.option('-q, --quiet', 'disable all process messaging except errors')
.option('-s, --silent', 'disable all process messaging')
.option('--no-optimize', 'disable optimization after plugin extraction')
.option(
'-c, --config <path>',
'path to the config file',
Expand Down
4 changes: 3 additions & 1 deletion src/cli_plugin/install/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ export default async function install(settings, logger) {

await renamePlugin(settings.workingPath, path.join(settings.pluginDir, settings.plugins[0].name));

await rebuildCache(settings, logger);
if (settings.optimize) {
await rebuildCache(settings, logger);
}

logger.log('Plugin installation complete');
} catch (err) {
Expand Down
1 change: 1 addition & 0 deletions src/cli_plugin/install/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export function parse(command, options, kbnPackage) {
quiet: options.quiet || false,
silent: options.silent || false,
config: options.config || '',
optimize: options.optimize,
plugin: command,
version: kbnPackage.version,
pluginDir: options.pluginDir || ''
Expand Down

0 comments on commit 1302cc2

Please sign in to comment.