Add optimize and --no-optimize flags (#16302)

* Add optimize flags

* update docs to --no-optimize

* docs

* extra newline

* lint

* update mocks

* update default config

* update snapshots
This commit is contained in:
Jonathan Budzenski 2018-09-17 12:45:51 -05:00 committed by Jonathan Budzenski
parent 8d5835d477
commit 0eb4f58bac
No known key found for this signature in database
GPG key ID: D28BF9418FA0F292
11 changed files with 39 additions and 2 deletions

View file

@ -68,6 +68,13 @@ If plugins were installed as a different user and the server is not starting, th
[source,shell]
$ chown -R kibana:kibana /path/to/kibana/optimize
[float]
=== Installing plugins while deferring optimization
The majority of the time spent installing a plugin is running the optimizer. If you're installing multiple plugins it can make sense to omit that step and only run it once.
This can be done by providing --no-optimize to the plugin installation command. You can then either execute bin/kibana --optimize to run the optimizer,
or it will be ran the first time Kibana is started.
[float]
=== Proxy support for plugin installation

View file

@ -110,6 +110,11 @@ function applyConfigOverrides(rawConfig, 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
@ -167,7 +172,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 (XPACK_OPTIONAL) {
command
@ -205,6 +212,7 @@ export default function (program) {
silent: !!opts.silent,
watch: !!opts.watch,
basePath: !!opts.basePath,
optimize: !!opts.optimize,
},
features: {
isClusterModeSupported: CAN_CLUSTER,
@ -214,4 +222,5 @@ export default function (program) {
applyConfigOverrides: rawConfig => applyConfigOverrides(rawConfig, opts, unknownOptions),
});
});
}

View file

@ -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',

View file

@ -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) {

View file

@ -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 || ''

View file

@ -76,6 +76,12 @@ export async function bootstrap({
await shutdown(err);
}
if (cliArgs.optimize) {
const cliLogger = root.logger.get('cli');
cliLogger.info('Optimization done.');
await shutdown();
}
process.on('SIGHUP', () => {
const cliLogger = root.logger.get('cli');
cliLogger.info('Reloading logging configuration due to SIGHUP.', { tags: ['config'] });

View file

@ -34,6 +34,7 @@ export function getEnvOptions(options: DeepPartial<EnvOptions> = {}): EnvOptions
silent: false,
watch: false,
basePath: false,
optimize: false,
...(options.cliArgs || {}),
},
isDevClusterMaster:

View file

@ -7,6 +7,7 @@ Env {
"basePath": false,
"dev": true,
"envName": "development",
"optimize": false,
"quiet": false,
"silent": false,
"watch": false,
@ -41,6 +42,7 @@ Env {
"basePath": false,
"dev": false,
"envName": "production",
"optimize": false,
"quiet": false,
"silent": false,
"watch": false,
@ -74,6 +76,7 @@ Env {
"cliArgs": Object {
"basePath": false,
"dev": true,
"optimize": false,
"quiet": false,
"silent": false,
"watch": false,
@ -107,6 +110,7 @@ Env {
"cliArgs": Object {
"basePath": false,
"dev": false,
"optimize": false,
"quiet": false,
"silent": false,
"watch": false,
@ -140,6 +144,7 @@ Env {
"cliArgs": Object {
"basePath": false,
"dev": false,
"optimize": false,
"quiet": false,
"silent": false,
"watch": false,
@ -173,6 +178,7 @@ Env {
"cliArgs": Object {
"basePath": false,
"dev": false,
"optimize": false,
"quiet": false,
"silent": false,
"watch": false,

View file

@ -48,6 +48,7 @@ export interface CliArgs {
silent: boolean;
watch: boolean;
basePath: boolean;
optimize: boolean;
}
export class Env {

View file

@ -6,6 +6,7 @@ Array [
Object {
"basePath": true,
"dev": true,
"optimize": false,
"quiet": true,
"silent": false,
"watch": false,
@ -57,6 +58,7 @@ Array [
Object {
"basePath": false,
"dev": true,
"optimize": false,
"quiet": false,
"silent": true,
"watch": false,

View file

@ -61,6 +61,7 @@ export function createRootWithSettings(...settings: Array<Record<string, any>>)
silent: false,
watch: false,
basePath: false,
optimize: false,
},
isDevClusterMaster: false,
});