Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[optimizer] run webpack compilation ASAP (no more laziness) #15795

Merged
merged 2 commits into from Jan 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cli/serve/serve.js
Expand Up @@ -39,7 +39,7 @@ function readServerSettings(opts, extraCliOptions) {

if (opts.dev) {
set('env', 'development');
set('optimize.lazy', true);
set('optimize.watch', true);

if (opts.ssl) {
set('server.ssl.enabled', true);
Expand Down
8 changes: 4 additions & 4 deletions src/optimize/index.js
Expand Up @@ -4,17 +4,17 @@ import { createBundlesRoute } from './bundles_route';
export default async (kbnServer, server, config) => {
if (!config.get('optimize.enabled')) return;

// the lazy optimizer sets up two threads, one is the server listening
// the watch optimizer sets up two threads, one is the server listening
// on 5601 and the other is a server listening on 5602 that builds the
// bundles in a "middleware" style.
//
// the server listening on 5601 may be restarted a number of times, depending
// on the watch setup managed by the cli. It proxies all bundles/* requests to
// the other server. The server on 5602 is long running, in order to prevent
// complete rebuilds of the optimize content.
const lazy = config.get('optimize.lazy');
if (lazy) {
return await kbnServer.mixin(require('./lazy/lazy'));
const watch = config.get('optimize.watch');
if (watch) {
return await kbnServer.mixin(require('./watch/watch'));
}

const { uiBundles } = kbnServer;
Expand Down
119 changes: 0 additions & 119 deletions src/optimize/lazy/lazy_optimizer.js

This file was deleted.

58 changes: 0 additions & 58 deletions src/optimize/lazy/weird_control_flow.js

This file was deleted.

@@ -1,17 +1,17 @@
import LazyServer from './lazy_server';
import LazyOptimizer from './lazy_optimizer';
import WatchServer from './watch_server';
import WatchOptimizer from './watch_optimizer';

export default async (kbnServer, kibanaHapiServer, config) => {
const server = new LazyServer(
config.get('optimize.lazyHost'),
config.get('optimize.lazyPort'),
const server = new WatchServer(
config.get('optimize.watchHost'),
config.get('optimize.watchPort'),
config.get('server.basePath'),
new LazyOptimizer({
new WatchOptimizer({
log: (tags, data) => kibanaHapiServer.log(tags, data),
uiBundles: kbnServer.uiBundles,
profile: config.get('optimize.profile'),
sourceMaps: config.get('optimize.sourceMaps'),
prebuild: config.get('optimize.lazyPrebuild'),
prebuild: config.get('optimize.watchPrebuild'),
unsafeCache: config.get('optimize.unsafeCache'),
})
);
Expand Down
Expand Up @@ -8,8 +8,8 @@ export default (kbnServer, server, config) => {
method: 'GET',
handler: {
proxy: {
host: config.get('optimize.lazyHost'),
port: config.get('optimize.lazyPort'),
host: config.get('optimize.watchHost'),
port: config.get('optimize.watchPort'),
passThrough: true,
xforward: true
}
Expand All @@ -19,11 +19,11 @@ export default (kbnServer, server, config) => {

return fromNode(cb => {
const timeout = setTimeout(() => {
cb(new Error('Server timedout waiting for the optimizer to become ready'));
}, config.get('optimize.lazyProxyTimeout'));
cb(new Error('Timeout waiting for the optimizer to become ready'));
}, config.get('optimize.watchProxyTimeout'));

const waiting = once(() => {
server.log(['info', 'optimize'], 'Waiting for optimizer completion');
server.log(['info', 'optimize'], 'Waiting for optimizer to be ready');
});

if (!process.connected) return;
Expand Down
14 changes: 6 additions & 8 deletions src/optimize/lazy/lazy.js → src/optimize/watch/watch.js
Expand Up @@ -2,21 +2,19 @@ import { isWorker } from 'cluster';

export default async kbnServer => {


if (!isWorker) {
throw new Error(`lazy optimization is only available in "watch" mode`);
throw new Error(`watch optimization is only available when using the "--dev" cli flag`);
}

/**
* When running in lazy mode two workers/threads run in one
* of the modes: 'optmzr' or 'server'
* When running in watch mode two processes run in one of the following modes:
*
* optmzr: this thread runs the LiveOptimizer and the LazyServer
* which serves the LiveOptimizer's output and blocks requests
* optmzr: this process runs the WatchOptimizer and the WatchServer
* which serves the WatchOptimizer's output and blocks requests
* while the optimizer is running
*
* server: this thread runs the entire kibana server and proxies
* all requests for /bundles/* to the optmzr
* server: this process runs the entire kibana server and proxies
* all requests for /bundles/* to the optmzr process
*
* @param {string} process.env.kbnWorkerType
*/
Expand Down