-
Notifications
You must be signed in to change notification settings - Fork 12
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
Is there a way to skip bundling for a faster restart? #32
Comments
You need to update your server.js file (if you use generator-derby) to something like this (may contain some misspells, I've not tested it): var async = require('async');
var derby = require('derby');
var http = require('http');
var chalk = require('chalk');
var publicDir = process.cwd() + '/public';
derby.run(function(){
require('coffee-script/register');
require('./server/config');
var apps = [
require('./apps/app')
// <end of app list> - don't remove this comment
];
var express = require('./server/express');
var store = require('./server/store')(derby, publicDir);
var error = require('./server/error');
express(store, apps, error, publicDir, function(expressApp, upgrade){
var server = http.createServer(expressApp);
server.on('upgrade', upgrade);
function listenServer(){
server.listen(process.env.PORT, function() {
console.log('%d listening. Go to: http://localhost:%d/',
process.pid, process.env.PORT);
});
}
function bundleApp (app, cb) {
app.writeScripts(store, publicDir, {extensions: ['.coffee']}, function(err){
if (process.env.MODE === 'save') app.serialize();
if (err) {
console.log("Bundle don't created:", chalk.red(app.name), ', error:', err);
} else {
console.log('Bundle created:', chalk.blue(app.name));
}
cb();
});
}
switch (process.env.MODE) {
case ('use'): return listenServer();
case ('save'): return async.each(apps, bundleApp, process.exit.bind(process));
default: async.each(apps, bundleApp, listenServer);
}
});
}); After that you will be able to start your project three ways:
|
We use MODE=save in the deployment stage (while creating docker image) and MODE=use inside our docker container. Our 16 heavy apps start on 8 second. |
Thanks 👍 from 2 minutes to less than 3 seconds |
For anyone who wants to try this out on his development machine: |
Yeah, for the purpose we use npm-script in our
So, |
It would be really nice if the browserify / bundling step could be skipped, for example when the server crashes and forever or pm2 or whatever restarts the app. The bundling can take quite a lot of time, especially when in NODE_ENV=production mode.
I'm talking about simply reusing the latest bundled .js file.
The text was updated successfully, but these errors were encountered: