def METHOD_NAME():
    app = create_app(config_name='production', silent=True)
    with app.app_context():
        queue = get_job_queue()
        if not isinstance(queue, HueyQueue):
            raise RuntimeError("{!r} is not a HueyQueue".format(queue))
    parser_handler = CustomOptionParserHandler()
    parser = parser_handler.get_option_parser()
    options, args = parser.parse_args()
    options = {k: v for k, v in options.__dict__.items()
               if v is not None}
    config = ConsumerConfig(**options)
    config.validate()
    # setup logging:
    log_config_file = app.config.get("PI_LOGCONFIG", "/etc/privacyidea/logging.cfg")
    # If the file does not exist, we reconfigure logging.
    if os.path.isfile(log_config_file):
        # If PI_LOGCONFIG points to an existing file, the user is responsible for configuring
        # huey logging in the logconfig file. In this case, we do nothing, because logging
        # has already been set up by ``create_app``.
        # But we ensure that the user hasn't passed ``-l``
        if config.logfile is not None:
            sys.stderr.write("-l is unsupported if PI_LOGCONFIG is used. Exiting.\n")
            sys.exit(1)
        print("Using logging configuration from {!r}".format(log_config_file))
    else:
        # If a logfile was given, we write to that logfile. If not, we write to ``privacyidea-queue.log``.
        if config.logfile is not None:
            logfile = config.logfile
        else:
            logfile = DEFAULT_LOGFILE
        loglevel = app.config.get("PI_LOGLEVEL", logging.INFO)
        log_config = make_logging_config(logfile, loglevel)
        logging.config.dictConfig(log_config)
        print("Logging to {!r}".format(logfile))
    queue.huey.register_pre_execute('push_app_context', make_push_app_context(app))
    queue.huey.register_post_execute('pop_app_context', pop_app_context)
    consumer = queue.huey.create_consumer(**config.values)
    consumer.run()