def start_pyres(self): # I don't think we actually need the scheduler in the tests. This is # likely a mistake. #self.scheduler = Popen( # args=['pyres_scheduler', '--port', str(self.redis_port)], # stdout=PIPE, stderr=STDOUT, #) # Needed because I can't seem to get the env parameter to Popen to work os.environ['PYTHONPATH'] = os.path.dirname(__file__) + '/../../..' self.worker = Popen( args=[ '%s/bin/worker' % os.environ['PYTHONPATH'], '--server=localhost:%d' %(self.redis_port), '--queue=Service', '--log=INFO', ], # stdout=PIPE, stderr=STDOUT, ) d = ResQ.connect( server=':'.join([ 'localhost', str(self.redis_port), ]), ) def set_resq(resq): self.resq = resq d.addCallback(set_resq) return d
#!/usr/bin/env python import os import sys sys.path.append(os.path.dirname(__file__) + '/..') from twistedpyres import ResQ from twisted.internet import reactor d = ResQ.connect() if False: from lightning.service.loopback import LoopbackDaemon def enqueue(resq): return resq.enqueue(LoopbackDaemon, { 'redis':{ 'host': 'localhost', 'port': 6379, }, 'environment': 'local', }, 'token_1234') d.addCallback(enqueue) else: from lightning.service.facebook import FacebookDaemon from lightning.service.instagram import InstagramDaemon from lightning.service.twitter import TwitterDaemon from lightning.service.loopback import LoopbackDaemon def enqueue(resq): return resq.enqueue(FacebookDaemon, { 'sql':{ 'connection':'dsn=SQLServer;uid=fakeuser;pwd=fakepassword;database=LIGHTNING;driver={SQL Server Native Client 10.0}',