Exemplo n.º 1
0
# -*- coding: utf-8 -*-
"""
    manage.py
    ~~~~~~~~~

    Start some long-running worker processes
"""

from flask.ext.script import Manager
import json

from receiver import create_app
from receiver.core import kafka
from receiver.track import track_page_view

app = create_app()
manager = Manager(app)


@manager.command
def track():
    topic = kafka.topics.get('page_views')
    consumer = topic.get_simple_consumer()
    while consumer:
        line = consumer.consume().value
        # import pdb; pdb.set_trace()
        try:
            args = json.loads(line)
            assert isinstance(args, dict)
            track_page_view(args)
Exemplo n.º 2
0
# -*- coding: utf-8 -*-
"""
    wsgi
    ~~~~
    receiver wsgi module
"""

from werkzeug.serving import run_simple
from werkzeug.wsgi import DispatcherMiddleware

import receiver

application = DispatcherMiddleware(receiver.create_app())

if __name__ == "__main__":
    run_simple(
        '0.0.0.0', 5000, application,
        use_reloader=True, use_debugger=True)
Exemplo n.º 3
0
from receiver import create_app

app = create_app()
Exemplo n.º 4
0
def build_app(confs):
    logging.basicConfig(level=getattr(logging, confs["LogLevel"].upper()))
    app = receiver.create_app(confs.value)
    return app