Skip to content

Instantly share code, notes, and snippets.

@justindossey
Created March 30, 2012 21:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justindossey/2255384 to your computer and use it in GitHub Desktop.
Save justindossey/2255384 to your computer and use it in GitHub Desktop.
Flip read_secondary via MongoMapper
trap('USR2') do
# reconnect to MongoDB with read_secondary reversed
result=MongoMapper.connection.instance_eval('@read_secondary = !@read_secondary')
logger.notice("#{Time.now}: now reading from #{result ? 'secondary' : 'primary'}")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment