Sha256: 1e274afe669cf2e7c8f50a217968308b4b4ea14cbc6b8ee17a9573d2a4cb1a7a

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

require 'mongrel' if Puppet.features.mongrel?

require 'puppet/network/http/mongrel/rest'

class Puppet::Network::HTTP::Mongrel
  def initialize(args = {})
    @listening = false
  end

  def listen(args = {})
    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(args[:address], args[:port])
    @server.register('/', Puppet::Network::HTTP::MongrelREST.new(:server => @server))

    @listening = true
    @server.run
  end

  def unlisten
    raise "Mongrel server is not listening" unless listening?
    # We wait until the running process has terminated, rather than letting
    # the shutdown happen in the background.  This might delay exit, but is
    # nicer than the alternative of killing something horribly. --daniel 2012-03-12
    @server.stop(true)
    @server = nil
    @listening = false
  end

  def listening?
    @listening
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
puppet-3.0.0.rc5 lib/puppet/network/http/mongrel.rb
puppet-3.0.0.rc4 lib/puppet/network/http/mongrel.rb