mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-03-14 07:00:01 -04:00
This commit is contained in:
commit
912b6140ac
3 changed files with 14 additions and 9 deletions
|
@ -43,7 +43,7 @@
|
|||
"passport": "0.1.x",
|
||||
"passport-local": "0.1.x",
|
||||
"mongodb": "1.2.x",
|
||||
"mongoose": "3.6.x",
|
||||
"mongoose": "3.8.x",
|
||||
"mongoose-text-search": "~0.0.2",
|
||||
"request": "2.12.x",
|
||||
"tv4": "1.0.x",
|
||||
|
|
|
@ -39,14 +39,18 @@ schemas =
|
|||
|
||||
|
||||
module.exports.connectDatabase = () ->
|
||||
dbName = config.mongo.db
|
||||
dbName += '_unittest' if testing
|
||||
address = config.mongo.host + ":" + config.mongo.port
|
||||
if config.mongo.username and config.mongo.password
|
||||
address = config.mongo.username + ":" + config.mongo.password + "@" + address
|
||||
# address = config.mongo.username + "@" + address # if connecting to production server
|
||||
address = "mongodb://#{address}/#{dbName}"
|
||||
console.log "got address:", address
|
||||
if config.mongo.mongoose_replica_string
|
||||
address = config.mongo.mongoose_replica_string
|
||||
winston.info "Connecting to replica set: #{address}"
|
||||
else
|
||||
dbName = config.mongo.db
|
||||
dbName += '_unittest' if testing
|
||||
address = config.mongo.host + ":" + config.mongo.port
|
||||
if config.mongo.username and config.mongo.password
|
||||
address = config.mongo.username + ":" + config.mongo.password + "@" + address
|
||||
# address = config.mongo.username + "@" + address # if connecting to production server
|
||||
address = "mongodb://#{address}/#{dbName}"
|
||||
winston.info "Connecting to standalone server #{address}"
|
||||
mongoose.connect address
|
||||
mongoose.connection.once 'open', ->
|
||||
Grid.gfs = Grid(mongoose.connection.db, mongoose.mongo)
|
||||
|
|
|
@ -10,6 +10,7 @@ config.mongo = {};
|
|||
config.mongo.port = process.env.COCO_MONGO_PORT || 27017;
|
||||
config.mongo.host = process.env.COCO_MONGO_HOST || 'localhost';
|
||||
config.mongo.db = process.env.COCO_MONGO_DATABASE_NAME || 'coco';
|
||||
config.mongo.mongoose_replica_string = process.env.COCO_MONGO_MONGOOSE_REPLICA_STRING || '';
|
||||
|
||||
if(config.unittest) {
|
||||
config.port += 1;
|
||||
|
|
Loading…
Reference in a new issue