mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-23 23:58:02 -05:00
Added support for replica set
This commit is contained in:
parent
e920054695
commit
3256a5d65d
2 changed files with 13 additions and 8 deletions
|
@ -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