예제 #1
0
 def setUp(self):
     connection_string = app_settings.get_connection_string()
     connection_pool = DictRowConnectionPool(
         None, connection_string, min=app_settings.API_MIN_CONNECTIONS)
     self.connection_pool = yield connection_pool.start()
     root = api.Root(connection_pool)
     self.web = DummySite(root)
예제 #2
0
    def handle(self, *args, **options):
        """Run the Billing server"""

        def connection_established(connection_pool):
            from twisted.web.server import Site
            root = api.Root(connection_pool)
            site = Site(root)
            endpoint = serverFromString(
                reactor, app_settings.ENDPOINT_DESCRIPTION_STRING)

            endpoint.listen(site)
            reactor.callWhenRunning(
                lambda _: _.stdout.write(
                    "Billing server is running on %s\n" %
                    app_settings.ENDPOINT_DESCRIPTION_STRING), self)

        def connection_error(err):
            self.stderr.write(err)

        log.startLogging(sys.stdout)
        connection_string = app_settings.get_connection_string()
        connection_pool = DictRowConnectionPool(
            None, connection_string, min=app_settings.API_MIN_CONNECTIONS)

        self.stdout.write("Connecting to database %s..." %
                          (connection_string,))

        d = connection_pool.start()
        d.addCallbacks(connection_established, connection_error)
        reactor.run()