-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
49 lines (38 loc) · 1.3 KB
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
var async = require('async');
var derby = require('derby');
var http = require('http');
var chalk = require('chalk');
var publicDir = process.cwd() + '/public';
derby.use(require('racer-bundle'));
derby.run(function(){
require('coffee-script/register');
require('./server/config');
var apps = [
require('./apps/derby-bugreport1')
, require('./apps/derby-bugreport2')
// <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);
async.each(apps, bundleApp, function(){
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 (err) {
console.log("Bundle don't created:", chalk.red(app.name), ', error:', err);
} else {
console.log('Bundle created:', chalk.blue(app.name));
}
cb();
});
}
});
});