Пример #1
0
def main():
    signal.signal(signal.SIGINT, sigint_handler)

    from iris.api import get_api, load_config

    config = load_config()
    app = get_api(config)

    server = config['server']
    print 'LISTENING: %(host)s:%(port)d' % server
    server = WSGIServer((server['host'], server['port']), app)

    if HAS_INOTIFY:
        fd = inotify.init()

        for dirname, subfolders, _ in os.walk('.'):
            if '.git' in subfolders:
                subfolders.remove('.git')
            inotify.add_watch(fd, dirname, inotify.IN_MODIFY)

        gevent.spawn(event_producer, fd, server)
    else:
        print 'Missing inotify, disable watch support.'
    server.serve_forever()
Пример #2
0
#!/usr/bin/env python
# -*- coding:utf-8 -*-

from gevent import monkey
monkey.patch_all()  # NOQA

from gevent.pywsgi import WSGIServer
import sys
from iris.api import get_api
from iris.config import load_config

if __name__ == '__main__':

    def clean_exit(a, b):
        import sys
        sys.exit(0)

    import signal
    signal.signal(signal.SIGTERM, clean_exit)

    config = load_config(sys.argv[1])
    addr = (config['server']['host'], config['server']['port'])
    print('Listening on %s...' % (addr, ))
    application = get_api(config)
    WSGIServer(addr, application).serve_forever()
Пример #3
0
import os
import logging
from iris.config import load_config
from iris.api import get_api

logging.basicConfig(format='[%(asctime)s] [%(process)d] [%(levelname)s] %(name)s %(message)s',
                    level=logging.INFO, datefmt='%Y-%m-%d %H:%M:%S %z')
application = get_api(load_config(os.environ['CONFIG']))