lib/right_chimp/daemon/ChimpDaemon.rb in right_chimp-2.1.13 vs lib/right_chimp/daemon/ChimpDaemon.rb in right_chimp-2.1.14
- old
+ new
@@ -6,19 +6,21 @@
module Chimp
class ChimpDaemon
attr_accessor :verbose, :debug, :port, :concurrency, :delay, :retry_count,
- :dry_run, :logfile, :chimp_queue, :proc_counter, :semaphore
+ :dry_run, :logfile, :chimp_queue, :proc_counter, :semaphore,
+ :bind_address
attr_reader :queue, :running
include Singleton
def initialize
@verbose = false
@debug = false
@port = 9055
+ @bind_address = "localhost"
@concurrency = 50
@delay = 0
@retry_count = 0
@threads = []
@running = false
@@ -58,10 +60,11 @@
[ '--quiet', '-q', GetoptLong::NO_ARGUMENT ],
[ '--concurrency', '-c', GetoptLong::REQUIRED_ARGUMENT ],
[ '--delay', '-d', GetoptLong::REQUIRED_ARGUMENT ],
[ '--retry', '-y', GetoptLong::REQUIRED_ARGUMENT ],
[ '--port', '-p', GetoptLong::REQUIRED_ARGUMENT ],
+ [ '--bind-address', '-b', GetoptLong::REQUIRED_ARGUMENT ],
[ '--help', '-h', GetoptLong::NO_ARGUMENT ],
[ '--exit', '-x', GetoptLong::NO_ARGUMENT ]
)
opts.each do |opt, arg|
@@ -79,20 +82,22 @@
@verbose = true
when '--quiet', '-q'
@quiet = true
when '--port', '-p'
@port = arg
+ when '--bind-address', '-b'
+ @bind_address = arg.to_s
when '--help', '-h'
help
when '--exit', '-x'
uri = "http://localhost:#{@port}/admin"
response = RestClient.post uri, { 'shutdown' => true }.to_yaml
exit 0
end
end
rescue GetoptLong::InvalidOption => ex
- puts "Syntax: chimpd [--logfile=<name>] [--concurrency=<c>] [--delay=<d>] [--retry=<r>] [--port=<p>] [--verbose]"
+ puts "Syntax: chimpd [--logfile=<name>] [--concurrency=<c>] [--delay=<d>] [--retry=<r>] [--port=<p>] [--bind-address=<addr> ] [--verbose]"
exit 1
end
#
# Set up logging/verbosity
@@ -117,11 +122,11 @@
#
def help
puts
puts "chimpd -- a RightScale Platform command-line tool"
puts
- puts "Syntax: chimpd [--logfile=<name>] [--concurrency=<c>] [--delay=<d>] [--retry=<r>] [--port=<p>] [--verbose]"
+ puts "Syntax: chimpd [--logfile=<name>] [--concurrency=<c>] [--delay=<d>] [--retry=<r>] [--port=<p>] [--bind-address=<addr> ] [--verbose]"
puts
puts "Options:"
puts
puts " --logfile=<name> Specifiy the desired log location"
puts " --concurrency=<n> Specify the level of concurrent actions"
@@ -130,10 +135,11 @@
puts
puts " --verbose Run chimpd in verbose mode."
puts " --quiet Supress non-essential output"
puts
puts " --port=<port> Specify the port number for chimpd to listen on (default: 9055)"
+ puts " --bind-address=<addr> Specify an interface address for chimpd to bind to. 0.0.0.0 allows all, default is 'localhost'"
puts
puts " --help Displays this menu"
puts
exit 0
end
@@ -152,10 +158,10 @@
#
# Spawn a WEBrick Web server
#
def spawn_webserver
opts = {
- :BindAddress => "localhost",
+ :BindAddress => @bind_address,
:Port => @port,
:MaxClients => 500,
:RequestTimeout => 120,
:DoNotReverseLookup => true
}