Change how we connect to the analytics database.

This commit is contained in:
Rob 2016-09-02 15:57:26 -07:00
parent 3dcfa2cc8a
commit 888d43fc5c
2 changed files with 6 additions and 1 deletions

View file

@ -30,7 +30,7 @@ AnalyticsLogEventSchema.statics.logEvent = (user, event, properties={}) ->
unless config.proxy
analyticsMongoose = mongoose.createConnection()
analyticsMongoose.open "mongodb://#{config.mongo.analytics_host}:#{config.mongo.analytics_port}/#{config.mongo.analytics_db}", (error) ->
analyticsMongoose.open config.mongo.analytics_replica_string, (error) ->
log.error "Couldn't connect to analytics", error if error
module.exports = AnalyticsLogEvent = analyticsMongoose.model('analytics.log.event', AnalyticsLogEventSchema, config.mongo.analytics_collection)

View file

@ -25,6 +25,11 @@ config.mongo =
mongoose_replica_string: process.env.COCO_MONGO_MONGOOSE_REPLICA_STRING or ''
readpref: process.env.COCO_MONGO_READPREF or 'primary'
if process.env.COCO_MONGO_ANALYTICS_REPLICA_STRING?
config.mongo.analytics_replica_string = process.env.COCO_MONGO_ANALYTICS_REPLICA_STRING
else
config.mongo.analytics_replica_string = "mongodb://#{config.mongo.analytics_host}:#{config.mongo.analytics_port}/#{config.mongo.analytics_db}"
if process.env.COCO_MONGO_LS_REPLICA_STRING?
config.mongo.level_session_replica_string = process.env.COCO_MONGO_LS_REPLICA_STRING