diff options
author | Rick Bradley <rick@rickbradley.com> | 2007-10-15 14:47:25 -0500 |
---|---|---|
committer | Rick Bradley <rick@rickbradley.com> | 2007-10-15 14:47:25 -0500 |
commit | c34efbccf1eec9957253d4fcdcb4ea9c79837ad8 (patch) | |
tree | ae04acf64b2b2a772c9d7d113fccf994fc6c71a3 /lib | |
parent | 9a179ec3a9df62c6179e7151831c4f07197cfbce (diff) | |
download | puppet-c34efbccf1eec9957253d4fcdcb4ea9c79837ad8.tar.gz puppet-c34efbccf1eec9957253d4fcdcb4ea9c79837ad8.tar.xz puppet-c34efbccf1eec9957253d4fcdcb4ea9c79837ad8.zip |
Hooking up address/port support for the various servers w/ specs. Still need to start up a webrick server w/ address + port (this is far too incestuous with Puppet lib & Puppet.start at the moment).
Diffstat (limited to 'lib')
-rw-r--r-- | lib/puppet/network/http/mongrel.rb | 6 | ||||
-rw-r--r-- | lib/puppet/network/http/webrick.rb | 5 | ||||
-rw-r--r-- | lib/puppet/network/server.rb | 6 |
3 files changed, 13 insertions, 4 deletions
diff --git a/lib/puppet/network/http/mongrel.rb b/lib/puppet/network/http/mongrel.rb index 49449cf59..bbba69fe3 100644 --- a/lib/puppet/network/http/mongrel.rb +++ b/lib/puppet/network/http/mongrel.rb @@ -6,9 +6,11 @@ class Puppet::Network::HTTP::Mongrel end def listen(args = {}) - raise ArgumentError if args.keys.empty? + raise ArgumentError, ":handlers must be specified." if !args[:handlers] or args[:handlers].keys.empty? + raise ArgumentError, ":address must be specified." unless args[:address] + raise ArgumentError, ":port must be specified." unless args[:port] raise "Mongrel server is already listening" if listening? - @server = Mongrel::HttpServer.new("0.0.0.0", "3000") + @server = Mongrel::HttpServer.new(args[:address], args[:port]) @server.run @listening = true end diff --git a/lib/puppet/network/http/webrick.rb b/lib/puppet/network/http/webrick.rb index 85a329454..c22bce938 100644 --- a/lib/puppet/network/http/webrick.rb +++ b/lib/puppet/network/http/webrick.rb @@ -7,8 +7,11 @@ class Puppet::Network::HTTP::WEBrick < WEBrick::HTTPServer end def listen(args = {}) - raise ArgumentError if args.keys.empty? + raise ArgumentError, ":handlers must be specified." if !args[:handlers] or args[:handlers].keys.empty? + raise ArgumentError, ":address must be specified." unless args[:address] + raise ArgumentError, ":port must be specified." unless args[:port] raise "WEBrick server is already listening" if listening? + # TODO / FIXME: this should be moved out of the wacky Puppet global namespace! Puppet.start @listening = true diff --git a/lib/puppet/network/server.rb b/lib/puppet/network/server.rb index 941cb9df1..0541c1c3b 100644 --- a/lib/puppet/network/server.rb +++ b/lib/puppet/network/server.rb @@ -1,9 +1,13 @@ class Puppet::Network::Server - attr_reader :server_type, :http_server_class, :protocols + attr_reader :server_type, :http_server_class, :protocols, :address, :port def initialize(args = {}) @server_type = Puppet[:servertype] or raise "No servertype configuration found." # e.g., WEBrick, Mongrel, etc. @http_server_class = http_server_class_by_type(@server_type) + @address = args[:address] || Puppet[:bindaddress] || + raise(ArgumentError, "Must specify :address or configure Puppet :bindaddress.") + @port = args[:port] || Puppet[:masterport] || + raise(ArgumentError, "Must specify :port or configure Puppet :masterport") @protocols = [] @listening = false @routes = {} |