mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 17:45:40 -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 = () ->
|
module.exports.connectDatabase = () ->
|
||||||
dbName = config.mongo.db
|
if config.mongo.mongoose_replica_string
|
||||||
dbName += '_unittest' if testing
|
address = config.mongo.mongoose_replica_string
|
||||||
address = config.mongo.host + ":" + config.mongo.port
|
winston.info "Connecting to replica set: #{address}"
|
||||||
if config.mongo.username and config.mongo.password
|
else
|
||||||
address = config.mongo.username + ":" + config.mongo.password + "@" + address
|
dbName = config.mongo.db
|
||||||
# address = config.mongo.username + "@" + address # if connecting to production server
|
dbName += '_unittest' if testing
|
||||||
address = "mongodb://#{address}/#{dbName}"
|
address = config.mongo.host + ":" + config.mongo.port
|
||||||
console.log "got address:", address
|
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.connect address
|
||||||
mongoose.connection.once 'open', ->
|
mongoose.connection.once 'open', ->
|
||||||
Grid.gfs = Grid(mongoose.connection.db, mongoose.mongo)
|
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.port = process.env.COCO_MONGO_PORT || 27017;
|
||||||
config.mongo.host = process.env.COCO_MONGO_HOST || 'localhost';
|
config.mongo.host = process.env.COCO_MONGO_HOST || 'localhost';
|
||||||
config.mongo.db = process.env.COCO_MONGO_DATABASE_NAME || 'coco';
|
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) {
|
if(config.unittest) {
|
||||||
config.port += 1;
|
config.port += 1;
|
||||||
|
|
Loading…
Reference in a new issue