mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-12-17 19:12:33 -05:00
Lets just use replica strings for level session connections.
This commit is contained in:
parent
cd47a9d4ea
commit
b2bdae274f
2 changed files with 11 additions and 18 deletions
|
@ -106,35 +106,32 @@ LevelSessionSchema.set('toObject', {
|
|||
return ret
|
||||
})
|
||||
|
||||
if config.mongo.level_session_host?
|
||||
if config.mongo.level_session_replica_string?
|
||||
levelSessionMongo = mongoose.createConnection()
|
||||
levelSessionMongo.open "mongodb://#{config.mongo.level_session_host}:#{config.mongo.level_session_port}/#{config.mongo.level_session_db}", (error) ->
|
||||
levelSessionMongo.open config.mongo.level_session_replica_string, (error) ->
|
||||
if error
|
||||
log.error "Couldnt connect to session mongo!", error
|
||||
else
|
||||
log.info "Connected to seperate level session server."
|
||||
log.info "Connected to seperate level session server with string", config.mongo.level_session_replica_string
|
||||
else
|
||||
levelSessionMongo = mongoose
|
||||
|
||||
LevelSession = levelSessionMongo.model('level.session', LevelSessionSchema, 'level.sessions')
|
||||
|
||||
if config.mongo.level_session_aux_host?
|
||||
if config.mongo.level_session_aux_replica_string?
|
||||
auxLevelSessionMongo = mongoose.createConnection()
|
||||
auxLevelSessionMongo.open "mongodb://#{config.mongo.level_session_aux_host}:#{config.mongo.level_session_aux_port}/#{config.mongo.level_session_aux_db}", (error) ->
|
||||
auxLevelSessionMongo.open config.mongo.level_session_aux_replica_string, (error) ->
|
||||
if error
|
||||
log.error "Couldnt connect to AUX session mongo!", error
|
||||
else
|
||||
log.info "Connected to seperate level AUX session server."
|
||||
log.info "Connected to seperate level AUX session server with string", config.mongo.level_session_aux_replica_string
|
||||
|
||||
auxLevelSession = auxLevelSessionMongo.model('level.session', LevelSessionSchema, 'level.sessions')
|
||||
|
||||
LevelSessionSchema.post 'save', (d) ->
|
||||
return unless d instanceof LevelSession
|
||||
console.log "Saving D", arguments
|
||||
o = d.toObject {transform: ((x, r) -> r), virtuals: false}
|
||||
console.log "Guess I should write", o
|
||||
auxLevelSession.collection.save o, {w:1}, (err, v) ->
|
||||
console.log err.stack if err
|
||||
console.log("update sent", arguments)
|
||||
log.error err.stack if err
|
||||
|
||||
module.exports = LevelSession
|
||||
|
|
|
@ -26,15 +26,11 @@ config.mongo =
|
|||
mongoose_tokyo_replica_string: process.env.COCO_MONGO_MONGOOSE_TOKYO_REPLICA_STRING or ''
|
||||
mongoose_saoPaulo_replica_string : process.env.COCO_MONGO_MONGOOSE_SAOPAULO_REPLICA_STRING or ''
|
||||
|
||||
if process.env.COCO_MONGO_LS_HOST? or process.env.COCO_MONGO_LS_DATABASE_NAME?
|
||||
config.mongo.level_session_host = process.env.COCO_MONGO_LS_HOST or process.env.COCO_MONGO_HOST or 'localhost'
|
||||
config.mongo.level_session_port = process.env.COCO_MONGO_LS_PORT or process.env.COCO_MONGO_PORT or 27017
|
||||
config.mongo.level_session_db = process.env.COCO_MONGO_LS_DATABASE_NAME or process.env.COCO_MONGO_DATABASE_NAME or 'coco'
|
||||
if process.env.COCO_MONGO_LS_REPLICA_STRING?
|
||||
config.mongo.level_session_replica_string = process.env.COCO_MONGO_LS_REPLICA_STRING
|
||||
|
||||
if process.env.COCO_MONGO_LS_AUX_HOST? and process.env.COCO_MONGO_LS_AUX_PORT? and process.env.COCO_MONGO_LS_AUX_DATABASE_NAME
|
||||
config.mongo.level_session_aux_host = process.env.COCO_MONGO_LS_AUX_HOST or process.env.COCO_MONGO_HOST or 'localhost'
|
||||
config.mongo.level_session_aux_port = process.env.COCO_MONGO_LS_AUX_PORT or process.env.COCO_MONGO_PORT or 27017
|
||||
config.mongo.level_session_aux_db = process.env.COCO_MONGO_LS_AUX_DATABASE_NAME or 'coco_aux'
|
||||
if process.env.COCO_MONGO_LS_AUX_REPLICA_STRING?
|
||||
config.mongo.level_session_aux_replica_string = process.env.COCO_MONGO_LS_AUX_REPLICA_STRING
|
||||
|
||||
|
||||
if config.tokyo or config.saoPaulo
|
||||
|
|
Loading…
Reference in a new issue