* fixed start env

This commit is contained in:
tix 2016-12-25 02:54:44 +08:00
parent a6f0b35d04
commit 60a729ed0b
1 changed files with 7 additions and 11 deletions

16
app.js
View File

@ -7,18 +7,22 @@ var bodyParser = require('body-parser');
var ejs = require('ejs');
var fs = require('fs');
if (!process.env.NODE_ENV)
process.env.NODE_ENV = 'dev';
var mode = 'dev';
var prodArg = false;
for (var i in process.argv) {
if (process.argv[i] == '--prod')
prodArg = true;
}
if (process.env.NODE_ENV == 'dev' || process.env.NODE_ENV == 'development') {
console.log('server run as development mode');
global.Connections = require('./config/conn.dev.js');
}
if (process.env.NODE_ENV == 'prod' || process.env.NODE_ENV == 'production') {
if (process.env.NODE_ENV == 'prod' || process.env.NODE_ENV == 'production' || prodArg) {
console.log('server run as production mode');
global.Connections = require('./config/conn.prod.js');
mode = 'prod';
@ -70,14 +74,6 @@ app.use(function (err, req, res, next) {
module.exports = app;
var prodArg = false;
for (var i in process.argv) {
if (process.argv.hasOwnProperty(i)) {
if (process.argv[i] == '--prod')
prodArg = true;
}
}
var pg = require('./model/conn/pg_eco');
pg.connTest();