コード例 #1
0
def main():
    """main function
    """
    setup_options()

    app_name = 'twork'

    web_handlers = None
    timer_callback = None
    app_info = None
    settings = {}
    if options.app_module is not None:
        try:
            _module = import_object(options.app_module)

            web_handlers = _module.HANDLERS
            app_name = _module.APP_INFO.lower()
            app_info = _module.APP_INFO.upper()
            settings = _module.SETTINGS

            _module.setup()

            timer_callback = _module.timer_callback
            if options.timer_start:
                CommonTimer().start(timer_callback)
        except (ImportError, AttributeError) as e:
            gen_logger.error(e, exc_info=True)

    twork.utils.common.define_process_title('twork::{0}#{1}'.format(
        app_name, options.env))

    setup_log()

    _setup_signal()

    _log_options()

    gen_logger.info('START TORNADO SERVER ...')

    try:
        HTTPServer().start(web_handlers, app_info=app_info, **settings)

        tornado.ioloop.IOLoop.instance().start()
    except Exception as e:
        gen_logger.error('UnCaught Exception: %s', e, exc_info=True)
    finally:
        _quit()
コード例 #2
0
ファイル: tworkd.py プロジェクト: bufferx/twork
def main():
    """main function
    """
    setup_options()
    setup_log()
    _setup_signal()

    gen_logger.info('START TORNADO SERVER ...')

    app_name = 'twork'

    web_handlers   = None
    app_info       = None
    settings       = {}
    _module        = None
    if options.app_module is not None:
        try:
            _module = import_object(options.app_module)

            web_handlers = _module.HANDLERS
            app_name = _module.APP_INFO.lower()
            app_info = _module.APP_INFO.upper()
            settings = _module.SETTINGS
        except (ImportError, AttributeError) as e:
            gen_logger.error(e, exc_info=True)

    setup_options()
    _log_options()

    twork.utils.common.define_process_title('twork::{0}#{1}'.
            format(app_name, options.env))

    try:
        HTTPServer().start(web_handlers, app_info=app_info,
                twork_module=_module,
                **settings)

        _setup_cpu_affinity()

        tornado.ioloop.IOLoop.instance().start()
    except Exception as e:
        gen_logger.error('UnCaught Exception: %s', e, exc_info=True)
    finally:
        _quit()
コード例 #3
0
ファイル: tworkd.py プロジェクト: bufferx/twork
def _reopen_log(sig, frame):
    gen_logger.warning('Catch SIG: %d, ReOpen Log', sig)
    setup_log()
コード例 #4
0
def _reopen_log(sig, frame):
    gen_logger.warning('Catch SIG: %d, ReOpen Log', sig)
    setup_log()