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, __HOLE__) 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()
dataset/ETHPy150Open bufferx/twork/twork/tworkd.py/main