Wrap and return an application ready to be run.

    Args:
        settings (dict): a dictionary containing the settings, more info
            here http://docs.gunicorn.org/en/latest/settings.html

    Return:
        an initialized instance of the application.

def create_server(settings, log_config=None, bigchaindb_factory=None):
    """Wrap and return an application ready to be run.

    Args:
        settings (dict): a dictionary containing the settings, more info
            here http://docs.gunicorn.org/en/latest/settings.html

    Return:
        an initialized instance of the application.
    """

    settings = copy.deepcopy(settings)

    if not settings.get('workers'):
        settings['workers'] = (multiprocessing.cpu_count() * 2) + 1

    if not settings.get('threads'):
        # Note: Threading is not recommended currently, as the frontend workload
        # is largely CPU bound and parallisation across Python threads makes it
        # slower.
        settings['threads'] = 1

    settings['custom_log_config'] = log_config
    app = create_app(debug=settings.get('debug', False),
                     threads=settings['threads'],
                     bigchaindb_factory=bigchaindb_factory)
    standalone = StandaloneApplication(app, options=settings)
    return standalone