Exemple #1
0
    def start_server(self, config=None):
        '''Starts a junebug server. Stores the service to "self.service", and
        the url at "self.url"'''
        # TODO: This setup is very manual, because we don't call
        # service.startService. This must be fixed to close mirror the real
        # program with our tests.
        if config is None:
            config = yield self.create_channel_config()
        self.service = JunebugService(config)
        self.api = JunebugApi(self.service, config)
        self.service.api = self.api

        redis = yield self.get_redis()
        yield self.api.setup(redis, self.get_message_sender())

        self.config = self.api.config
        self.redis = self.api.redis
        self.inbounds = self.api.inbounds
        self.outbounds = self.api.outbounds
        self.message_sender = self.api.message_sender

        port = reactor.listenTCP(0,
                                 Site(self.api.app.resource()),
                                 interface='127.0.0.1')
        self.service._port = port
        self.addCleanup(self.stop_server)
        addr = port.getHost()
        self.url = "http://%s:%s" % (addr.host, addr.port)
Exemple #2
0
 def startService(self):
     '''Starts the HTTP server, and returns the port object that the server
     is listening on'''
     super(JunebugService, self).startService()
     self.api = JunebugApi(self, self.config)
     yield self.api.setup()
     self._port = reactor.listenTCP(
         self.config.port, Site(self.api.app.resource()),
         interface=self.config.interface)
     log.msg(
         'Junebug is listening on %s:%s' %
         (self.config.interface, self.config.port))