Пример #1
0
    locale_path="./locale",
    login_url="/auth/login",
    cookie_secret="32oETzKXQAGaYdkL5gEmGeJJFuYh7EQnp2XdTP1o/Vo=",
    base_handler=BaseHandler,
    db_handlers=cyclone.util.ObjectDict(
        #sqlite=cyclone.sqlite.InlineSQLite(":memory:"),
        redis=cyclone.redis.lazyConnectionPool(), ),
    more_handlers=[
        (r"/websocket", WebSocketHandler),
        (r"/xmlrpc", XmlrpcHandler),
    ])

application = service.Application("Application")

webservice = internet.TCPServer(int(os.getenv('PORT', 8888)),
                                bottle_app,
                                interface=os.getenv('LISTTEN', "0.0.0.0"))
webservice.setServiceParent(application)

from katoo.utils.connections import RedisMixin
from katoo.rqtwisted.worker import Worker

RedisMixin.setup()

blocking_seconds = int(os.getenv('DEQUEUE_BLOCKTIME', 1))
workers = int(os.getenv('WORKERS', 1))

for i in xrange(workers):
    t = Worker(['default'])
    t.setServiceParent(application)
Пример #2
0
            ret = yield API(user.userid, conf.MACHINEID).logout(user.userid)
        except XMPPUserNotLogged as e:
            my_log.error('Exception launch %s', e)
        try:
            ret = yield API(user.userid).logout(user.userid)
        except XMPPUserNotLogged as e:
            my_log.error('Exception launch %s', e)

        #Perform a timeout
        ret = yield API(user.userid, 'default').login(user)

#        reactor.callLater(5, API(user.userid).login, user)
#        reactor.callLater(7, API(user.userid).update, user.userid, token="ya29.AHES6ZRDTu4pDWdA_LBrNWF1vnI5NEtdB8V0v6JN46QTaw")
#        reactor.callLater(10, API(user.userid).logout, user.userid)
#        reactor.callLater(20, API(user.userid).login, user)

#log.startLogging(sys.stdout)

    app = KatooApp().app
    w = Worker([conf.MACHINEID, conf.DIST_QUEUE_LOGIN],
               name=conf.MACHINEID,
               loops=conf.REDIS_WORKERS)
    w.log = getLoggerAdapter(getLogger('WORKER', level='INFO'), id='WORKER')
    w.setServiceParent(app)
    KatooApp().service.startService()
    reactor.callLater(5, example)
    import twisted.python.log
    twisted.python.log.startLoggingWithObserver(KatooApp().log.emit)
    reactor.callLater(50, reactor.stop)
    reactor.run()