Removed log for deploy (optimize space on the cloud)

This commit is contained in:
Thomas FORGIONE 2015-06-25 17:21:19 +02:00
parent e915fb58e7
commit 3c2599f29b
3 changed files with 17 additions and 11 deletions

View File

@ -7,6 +7,9 @@ var fs = require('fs');
module.exports = function(parent, options){ module.exports = function(parent, options){
var verbose = options.verbose; var verbose = options.verbose;
verbose && console.log("Loading controllers :");
fs.readdirSync(__dirname + '/../controllers').forEach(function(name){ fs.readdirSync(__dirname + '/../controllers').forEach(function(name){
// index.js in controller, with function as pages (views.py for django) // index.js in controller, with function as pages (views.py for django)
@ -27,9 +30,9 @@ module.exports = function(parent, options){
verbose && console.log('\t' + name + ':'); verbose && console.log('\t' + name + ':');
for (var key in urls) { for (var key in urls) {
app.get(key, obj[urls[key]]); app.get(key, obj[urls[key]]);
console.log('\t\t' + key + ' -> ' + name + '.' + urls[key]); verbose && console.log('\t\t' + key + ' -> ' + name + '.' + urls[key]);
} }
console.log(); verbose && console.log();
// mount the app // mount the app
parent.use(app); parent.use(app);

View File

@ -8,6 +8,8 @@ var fs = require('fs');
module.exports = function(parent, options){ module.exports = function(parent, options){
var verbose = options.verbose; var verbose = options.verbose;
verbose && console.log("Loading controllers :");
fs.readdirSync(__dirname + '/../posts').forEach(function(name){ fs.readdirSync(__dirname + '/../posts').forEach(function(name){
// index.js in controller, with function as pages (views.py for django) // index.js in controller, with function as pages (views.py for django)
@ -28,9 +30,9 @@ module.exports = function(parent, options){
verbose && console.log('\t' + name + ':'); verbose && console.log('\t' + name + ':');
for (var key in urls) { for (var key in urls) {
app.post(key, obj[urls[key]]); app.post(key, obj[urls[key]]);
console.log('\t\t' + key + ' -> ' + name + '.' + urls[key]); verbose && console.log('\t\t' + key + ' -> ' + name + '.' + urls[key]);
} }
console.log(); verbose && console.log();
// mount the app // mount the app
parent.use(app); parent.use(app);

View File

@ -18,6 +18,8 @@ var session = require('cookie-session');
var cookieParser = require('cookie-parser'); var cookieParser = require('cookie-parser');
var urls = require('./urls'); var urls = require('./urls');
var isDev = app.get('env') === 'development';
app.set('view engine', 'jade'); app.set('view engine', 'jade');
app.set('trust proxy', 1); app.set('trust proxy', 1);
@ -55,12 +57,10 @@ app.use(function(req, res, next) {
// }); // });
// Load controllers // Load controllers
console.log("Loading controllers :"); require('./lib/controllers')(app, { verbose: isDev });
require('./lib/controllers')(app, { verbose: !module.parent });
// Load post to log data from user study // Load post to log data from user study
console.log("Loading posts :"); require('./lib/posts')(app, { verbose: isDev });
require('./lib/posts')(app, { verbose: !module.parent });
// Static files // Static files
app.use('/static', express.static('static')); app.use('/static', express.static('static'));
@ -87,7 +87,7 @@ app.use(function(req, res) {
// Set ports and ip address // Set ports and ip address
var server_port, server_ip_address; var server_port, server_ip_address;
if ( app.get('env') === 'development' ) { if ( isDev ) {
server_port = 4000; server_port = 4000;
server_ip_address = 'localhost'; server_ip_address = 'localhost';
} else { } else {
@ -98,5 +98,6 @@ if ( app.get('env') === 'development' ) {
// Start server // Start server
http.listen(server_port, server_ip_address, function() { http.listen(server_port, server_ip_address, function() {
if (isDev)
console.log("Server ready : now listening " + server_ip_address + ":" + server_port); console.log("Server ready : now listening " + server_ip_address + ":" + server_port);
}); });