Sha256: 4a457c10af72fc266fe774e01411b6392abe439e27caca79be79f73d7d7f79c7

Contents?: true

Size: 1.6 KB

Versions: 1

Compression:

Stored size: 1.6 KB

Contents

#!/usr/bin/env ruby

require 'mongo-proxy'
require 'trollop'

opts = Trollop::options do
  version "mongo-proxy #{MongoProxy::VERSION} (c) Peter Bakkum"
  banner <<-END
mongo-proxy runs a local proxy server for MongoDB. It allows you to watch the MongoDB wire traffic, run hooks on it, and force traffic to be read-only. This command is intended for easy access, you can also access the same functionality with the MongoProxy class.

Usage:
    mongo-proxy [options]

Examples:

    mongo-proxy -P 27017 -p 29017 -r -d
    (runs a proxy at port 29017 to connect to a local mongo in read-only and debug mode)

More info can be found at the gem website at github.com/bakks/mongo-proxy

Command line options:

END

  opt :client_host, 'Set the host to bind the proxy socket on.', :default => '127.0.0.1', :short => 'h'
  opt :client_port, 'Set the port to bind the proxy socket on.', :default => 27018, :short => 'p'
  opt :server_host, 'Set the backend hostname which we proxy.', :default => '127.0.0.1', :short => 'H'
  opt :server_port, 'Set the backend port which we proxy.', :default => 27017, :short => 'P'
  opt :read_only, 'Prevent any traffic that writes to the database.', :default => false
  opt :motd, 'Set a message-of-the-day to display to clients when they connect.', :default => nil
  opt :verbose, 'Print out MongoDB wire traffic.', :default => true
  opt :debug, 'Print log lines in a more human-readible format.', :default => true
end

keys = [:client_host, :client_port, :server_host, :server_port, :read_only, :motd, :verbose, :debug]

args = {}
keys.each { |key| args[key] = opts[key] }

m = MongoProxy.new(args)
m.start

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mongo-proxy-1.0.0 bin/mongo-proxy