def application(config): app = Application("Scrapyd") http_port = int(environ.get('PORT', config.getint('http_port', 6800))) config.cp.set('scrapyd', 'database_url', environ.get('DATABASE_URL')) poller = Psycopg2QueuePoller(config) eggstorage = FilesystemEggStorage(config) scheduler = Psycopg2SpiderScheduler(config) environment = Environment(config) app.setComponent(IPoller, poller) app.setComponent(IEggStorage, eggstorage) app.setComponent(ISpiderScheduler, scheduler) app.setComponent(IEnvironment, environment) launcher = Launcher(config, app) timer = TimerService(5, poller.poll) webservice = TCPServer(http_port, server.Site(Root(config, app))) log.msg("Scrapyd web console available at http://localhost:%s/ (HEROKU)" % http_port) launcher.setServiceParent(app) timer.setServiceParent(app) webservice.setServiceParent(app) return app
def application(config): app = Application("Scrapyd") http_port = config.getint('http_port', 6800) portal = Portal(PublicHTMLRealm(config, app), [FilePasswordDB(str(config.get('passwd', '')))]) credentialFactory = DigestCredentialFactory("md5", "Go away") poller = QueuePoller(config) eggstorage = FilesystemEggStorage(config) scheduler = SpiderScheduler(config) environment = Environment(config) app.setComponent(IPoller, poller) app.setComponent(IEggStorage, eggstorage) app.setComponent(ISpiderScheduler, scheduler) app.setComponent(IEnvironment, environment) launcher = Launcher(config, app) timer = TimerService(5, poller.poll) webservice = TCPServer(http_port, server.Site(HTTPAuthSessionWrapper(portal, [credentialFactory]))) log.msg("Scrapyd web console available at http://localhost:%s/" % http_port) launcher.setServiceParent(app) timer.setServiceParent(app) webservice.setServiceParent(app) return app
def application(config): app = Application("Scrapyd") http_port = config.getint('http_port', 6800) poller = QueuePoller(config) eggstorage = FilesystemEggStorage(config) scheduler = SpiderScheduler(config) environment = Environment(config) app.setComponent(IPoller, poller) app.setComponent(IEggStorage, eggstorage) app.setComponent(ISpiderScheduler, scheduler) app.setComponent(IEnvironment, environment) launcher = Launcher(config, app) timer = TimerService(5, poller.poll) root = Root(config, app) root = configRoot(root, config) webservice = TCPServer(http_port, server.Site(root)) log.msg("Scrapyd web console available at http://localhost:%s/" % http_port) launcher.setServiceParent(app) timer.setServiceParent(app) webservice.setServiceParent(app) return app
def __init__(self, config, app): Launcher.__init__(self, config, app) self.config = config self.redis_connecton = redis.StrictRedis(host=config.get('REDIS_HOST'), port=config.get('REDIS_PORT'), db=0, password=config.get( 'REDIS_PASSWORD', ''))