summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorRick Bradley <rick@rickbradley.com>2007-10-15 12:16:48 -0500
committerRick Bradley <rick@rickbradley.com>2007-10-15 12:16:48 -0500
commite56406f15086eb483c00a2904d8a75518412a905 (patch)
tree6a0a062750906cdf92c8975208fc873ae1c0c542 /lib/puppet
parentec71e05a162ec299982b90707cc16231c608997b (diff)
downloadpuppet-e56406f15086eb483c00a2904d8a75518412a905.tar.gz
puppet-e56406f15086eb483c00a2904d8a75518412a905.tar.xz
puppet-e56406f15086eb483c00a2904d8a75518412a905.zip
Implementing listening state tracking for webrick and mongrel.
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/network/http/mongrel.rb8
-rw-r--r--lib/puppet/network/http/webrick.rb9
2 files changed, 13 insertions, 4 deletions
diff --git a/lib/puppet/network/http/mongrel.rb b/lib/puppet/network/http/mongrel.rb
index dbdd72d42..49449cf59 100644
--- a/lib/puppet/network/http/mongrel.rb
+++ b/lib/puppet/network/http/mongrel.rb
@@ -7,15 +7,19 @@ class Puppet::Network::HTTP::Mongrel
def listen(args = {})
raise ArgumentError if args.keys.empty?
- raise "Mongrel server is already listening" if @listening
+ raise "Mongrel server is already listening" if listening?
@server = Mongrel::HttpServer.new("0.0.0.0", "3000")
@server.run
@listening = true
end
def unlisten
- raise "Mongrel server is not listening" unless @listening
+ raise "Mongrel server is not listening" unless listening?
@server.graceful_shutdown
@listening = false
end
+
+ def listening?
+ @listening
+ end
end
diff --git a/lib/puppet/network/http/webrick.rb b/lib/puppet/network/http/webrick.rb
index 77e55a224..ffea60eba 100644
--- a/lib/puppet/network/http/webrick.rb
+++ b/lib/puppet/network/http/webrick.rb
@@ -8,14 +8,19 @@ class Puppet::Network::HTTP::WEBRick < WEBrick::HTTPServer
def listen(args = {})
raise ArgumentError if args.keys.empty?
- raise "WEBRick server is already listening" if @listening
+ 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
end
def unlisten
- raise "WEBRick server is not listening" unless @listening
+ raise "WEBRick server is not listening" unless listening?
shutdown
+ @listening = false
+ end
+
+ def listening?
+ @listening
end
end