Exemplo n.º 1
0
def start_manager():
    import gevent

    # Setup (but don't *really*) start Notifico so that our
    # database configuration is completely loaded.
    start()

    gevent.signal(signal.SIGQUIT, gevent.shutdown)

    r = redis.StrictRedis(
        host=config.REDIS_HOST,
        port=config.REDIS_PORT,
        db=config.REDIS_DB
    )

    bs = BotState(r)
    q = Queue()
    p = Process(target=wait_for_message, args=(q,))
    p.start()

    while True:
        try:
            m = q.get(False)
            if m['type'] == 'message':
                channel = m['channel']
                payload = m['payload']

                bs.send_to_channel(
                    payload['msg'],
                    channel['channel'],
                    channel['host'],
                    channel['port'],
                    channel['ssl']
                )
        except Empty:
            pass

        gevent.sleep(0.5)
Exemplo n.º 2
0
#!/usr/bin/env python2
# -*- coding: utf8 -*-
"""
Starts a local notifico notifico instance for debugging & developing.
"""
from notifico import start

if __name__ == '__main__':
    app = start(debug=True)
    app.run(host='0.0.0.0')