Skip to content

Instantly share code, notes, and snippets.

@gswallow
Created May 21, 2013 13:48
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 gswallow/5619904 to your computer and use it in GitHub Desktop.
Save gswallow/5619904 to your computer and use it in GitHub Desktop.
79 def step_down(host, seconds)
80 connection = connect(host)
81 if is_master?(connection)
82 admin = connection['admin']
83 cmd = BSON::OrderedHash.new
84 cmd['replSetStepDown'] = seconds
85 begin
86 admin.command(cmd, :check_response => true)
87 rescue Mongo::OperationFailure => e
88 raise "Could not step down. Perhaps MongoDB isn't healthy? (server said: #{e})"
89 rescue Mongo::ConnectionFailure
90 # reconfiguring destroys exisiting connections; live with it.
91 return true
92 end
93 end
94 end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment