71: def initialize(hash = {})
72: Puppet.info "Starting server for Puppet version %s" % Puppet.version
73:
74: if handlers = hash[:Handlers]
75: handler_instances = setup_handlers(handlers)
76: else
77: raise ServerError, "A server must have handlers"
78: end
79:
80: unless self.read_cert
81: if ca = handler_instances.find { |handler| handler.is_a?(Puppet::Network::Handler.ca) }
82: request_cert(ca)
83: else
84: raise Puppet::Error, "No certificate and no CA; cannot get cert"
85: end
86: end
87:
88: setup_webrick(hash)
89:
90: begin
91: super(hash)
92: rescue => detail
93: puts detail.backtrace if Puppet[:trace]
94: raise Puppet::Error, "Could not start WEBrick: %s" % detail
95: end
96:
97:
98: listeners.each { |sock|
99: sock.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
100: }
101:
102: Puppet.info "Listening on port %s" % hash[:Port]
103:
104:
105:
106:
107:
108:
109:
110:
111: servlet = Puppet::Network::XMLRPC::WEBrickServlet.new(
112: handler_instances)
113: self.mount("/RPC2", servlet)
114: end