Comments (5)
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:
- node server.js (usual way)
- MODE=save node server.js (to save bundles and so on)
- MODE=use node server.js (to start you project using just created bundles)
from generator-derby.
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.
from generator-derby.
Thanks 👍
from 2 minutes to less than 3 seconds
from generator-derby.
For anyone who wants to try this out on his development machine:
Once you have done a "MODE=save node server", derby creates a "derby-serialized" folder in each app folder. You need to delete those if you want to return to developing.
from generator-derby.
Yeah, for the purpose we use npm-script in our package.json
:
"clean": "find . -name 'derby-serialized' -type d | xargs /bin/rm -rf"
So, npm run clean
does the work for us
from generator-derby.
Related Issues (20)
- Bundle error silently ignored. HOT 1
- Bootstrap: Cannot find view dropdown HOT 3
- Derby-login + Racer-schema = No schema for collection: auths HOT 6
- derby-login HOT 2
- Dependencies empty in package.json - missing a step? HOT 3
- 404 Sorry, we can't find anything at /login. HOT 4
- derby.util.isProduction is undefined on client side HOT 3
- Error: Cannot find module 'derby-markdown'
- Are the peerDependencies correct? HOT 1
- misspelled: generator-derby/app/templates/apps/app/views/_register.bootsrap.html HOT 1
- /apps/error/styles/reset.styl not needed
- error on generate derby with one feature bootstrap
- v0.8.5 Error: Cannot find module '../util.js' HOT 4
- Generator Fails HOT 3
- Fix windows support right from the start on generated code HOT 1
- [Feature Request] Webpack support
- derby-login needs some update HOT 1
- Sessions don't work HOT 3
- Error with derby-login HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from generator-derby.