예제 #1
0
def update_args(ctx, instance, branch, commit, locals_path, requirements,
                setup_environment):
    """Check args and update ctx."""
    # Do the sanity checks.
    instance = cset("instance", instance)
    if not instance or not instance.isalnum():
        abort("You have to specify a proper alphanumeric instance name!")
    if branch is not None and commit is not None:
        abort("You can only deploy specific commit OR specific branch")
    commit and cset("commit", commit, force=True)
    branch and cset("branch", branch, force=True)
    cset("locals_path", locals_path)
    cset("requirements", get_boolean(requirements))
    cset("setup_environment", get_boolean(setup_environment))
    return ctx
예제 #2
0
def update_args(ctx, instance, branch, commit, locals_path, requirements,
        setup_environment):
    """Check args and update ctx."""
    # Do the sanity checks.
    instance = cset("instance", instance)
    if not instance or not instance.isalnum():
        abort("You have to specify a proper alphanumeric instance name!")
    if branch is not None and commit is not None:
        abort("You can only deploy specific commit OR specific branch")
    commit and cset("commit", commit, force=True)
    branch and cset("branch", branch, force=True)
    cset("locals_path", locals_path)
    cset("requirements", get_boolean(requirements))
    cset("setup_environment", get_boolean(setup_environment))
    return ctx
예제 #3
0
def deploy(conf_file=None,
           instance=None,
           branch=None,
           commit=None,
           locals_path=None,
           setup_environment=False,
           prompt=True,
           requirements=True):
    u"""Does a full deployment of the project code.
        You have to supply an ``instance`` name (the name of deployment
        target in colocation environment).

        ``conf_file`` should be a path to a properly formatted JSON
        configuration file that will override default values.

        If ``locals_path`` is specified this file is used as
        a local settings file.
        Arguments ``commit`` and ``branch`` can be used to deploy
        some specific state of the codebase.

    """
    # Get file configuration and update with args
    env['ctx'] = {}

    ctx = load_config_files(conf_file)
    ctx = update_args(ctx, instance, branch, commit, locals_path, requirements,
                      setup_environment)

    # Fill instance context.
    set_instance_conf()
    print_context()

    # Give user a chance to abort deployment.
    if prompt:
        confirm_or_abort(red("\nDo you want to continue?"))

    # Prepare server environment for deployment.
    show(yellow("Preparing project environment"))
    if get_boolean(setup_environment):
        prepare_global_env()

    # create folders
    prepare_target_env()

    # Fetch source code.
    fetch_project_code()

    # Upload target specific Django settings.
    upload_settings_files()

    if get_boolean(requirements):
        # Update Virtualenv packages.
        update_virtualenv()

    # Collect static files.
    collect_staticfiles()
    # Compile translation messages.
    # Make sure this folder exists before using compile_messages
    # compile_messages()
    # Update database schema.
    sync_db()

    # Uploads settings and scripts for services.
    configure_services()
    # Reload services to load new config.
    __reload_services(setup=setup_environment)
예제 #4
0
def deploy(conf_file=None, instance=None, branch=None, commit=None,
        locals_path=None, setup_environment=False, requirements=True):
    u"""Does a full deployment of the project code.
        You have to supply an ``instance`` name (the name of deployment
        target in colocation environment).

        ``conf_file`` should be a path to a properly formatted JSON
        configuration file that will override default values.

        If ``locals_path`` is specified this file is used as
        a local settings file.
        Arguments ``commit`` and ``branch`` can be used to deploy
        some specific state of the codebase.

    """
    # Get file configuration and update with args
    env['ctx'] = {}

    ctx = load_config_files(conf_file)
    ctx = update_args(ctx, instance, branch, commit, locals_path,
        requirements, setup_environment)

    # Fill instance context.
    set_instance_conf()
    print_context()

    # Give user a chance to abort deployment.
    confirm_or_abort(red("\nDo you want to continue?"))

    # Prepare server environment for deployment.
    show(yellow("Preparing project environment"))
    if get_boolean(setup_environment):
        prepare_global_env()

    # create folders
    prepare_target_env()

    # Fetch source code.
    fetch_project_code()

    # Upload target specific Django settings.
    upload_settings_files()

    # Setup database (this relies on settings)
    setup_database()

    if get_boolean(requirements):
        # Update Virtualenv packages.
        update_virtualenv()

    # Collect static files.
    collect_staticfiles()
    # Compile translation messages.
    # Make sure this folder exists before using compile_messages
    # compile_messages()
    # Update database schema.
    sync_db()
    # Uploads settings and scripts for services.
    configure_services()
    # Reload services to load new config.
    __reload_services()

    # Configure and build documentation
    doc.configure()
    doc.build()