From 145c563171e521806737618b97ce963f22aaa75d Mon Sep 17 00:00:00 2001 From: Toan Vo Date: Mon, 24 Oct 2016 14:09:10 +0700 Subject: [PATCH 1/4] updated README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 10e485f5..93258f6f 100755 --- a/README.md +++ b/README.md @@ -85,17 +85,17 @@ Create this directory or you will get errors. mkdir uploads/pdfs ``` -Edit the 'env' config in gruntfile.js to make sure your .env file is being used. If you don't include this your app won't run +Edit the `env` config in gruntfile.js to make sure your .env file is being used. If you don't include this your app won't run To run development version: Set ```NODE_ENV=development``` in .env file -```$ grunt```` +```$ grunt``` To run production version: -Set ```NODE_ENV=development``` in .env file -```$ grunt```` +Set ```NODE_ENV=production``` in .env file +```$ grunt``` Your application should run on port 3000 or the port you specified in your .env file, so in your browser just go to [http://localhost:3000](http://localhost:3000) From 79f8ca8d85f244a3b460b339a65bfa068e85861e Mon Sep 17 00:00:00 2001 From: Toan Vo Date: Mon, 24 Oct 2016 14:13:38 +0700 Subject: [PATCH 2/4] only load dotenv if development environment --- server.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/server.js b/server.js index 13074a4e..76a3edd0 100755 --- a/server.js +++ b/server.js @@ -4,7 +4,9 @@ */ //Load ENV vars from .env -require('dotenv').config(); +if ((process.env.NODE_ENV || 'development') === 'development') { + require('dotenv').config(); +} var init = require('./config/init')(), config = require('./config/config'), @@ -18,13 +20,13 @@ var init = require('./config/init')(), */ // Bootstrap db connection -var db = mongoose.connect(config.db.uri, config.db.options, function(err) { +var db = mongoose.connect(config.db.uri, config.db.options, function (err) { if (err) { console.error(chalk.red('Could not connect to MongoDB!')); console.log(chalk.red(err)); } }); -mongoose.connection.on('error', function(err) { +mongoose.connection.on('error', function (err) { console.error(chalk.red('MongoDB connection error: ' + err)); process.exit(-1); }); From 45723bc725b5e54a74e6ee2a8e130d9dbeec793a Mon Sep 17 00:00:00 2001 From: Toan Vo Date: Mon, 24 Oct 2016 15:24:25 +0700 Subject: [PATCH 3/4] db url --- config/env/production.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/config/env/production.js b/config/env/production.js index 170830a1..42ae875a 100755 --- a/config/env/production.js +++ b/config/env/production.js @@ -3,13 +3,9 @@ module.exports = { baseUrl: process.env.BASE_URL || 'tellform.com', db: { - uri: process.env.MONGOHQ_URL || process.env.MONGOLAB_URI || 'mongodb://' + (process.env.DB_1_PORT_27017_TCP_ADDR || 'localhost') + '/mean', - options: { - user: '', - pass: process.env.MONGOLAB_PASS || '' - } + uri: process.env.MONGODB_URI }, - port: process.env.PORT || 4545, + port: process.env.PORT || 5000, log: { // Can specify one of 'combined', 'common', 'dev', 'short', 'tiny' format: 'combined', From 4f503e6dfb70d73bb92a17b175a1bae964bd5138 Mon Sep 17 00:00:00 2001 From: Toan Vo Date: Mon, 24 Oct 2016 15:27:03 +0700 Subject: [PATCH 4/4] update redis url --- config/socket.io.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/socket.io.js b/config/socket.io.js index fe44f355..d710b712 100644 --- a/config/socket.io.js +++ b/config/socket.io.js @@ -12,7 +12,7 @@ module.exports = function (app, db) { var io = socketio(config.socketPort, { transports: ['websocket', 'polling'] }); var redis = require('socket.io-redis'); - io.adapter(redis(process.env.REDIS_HOST || { host: '127.0.0.1', port: 6379 })); + io.adapter(redis(process.env.REDIS_URL || { host: '127.0.0.1', port: 6379 })); // Add an event listener to the 'connection' event io.on('connection', function (socket) {