Exemple #1
0
def start_or_reload_service(has_started=False):
    ''' Start or reload the application service. '''
    with cd(buildman.get_deploy_dir()):
        if runner.is_script_defined(known_scripts.START_OR_RELOAD):
            remote_info('Starting/Reloading the service.')
            runner.run_script(known_scripts.START_OR_RELOAD)

        elif has_started and runner.is_script_defined(known_scripts.RELOAD):
            remote_info('Reloading the service.')
            runner.run_script_safely(known_scripts.RELOAD)

        elif runner.is_script_defined(known_scripts.START):
            remote_info('Starting the service.')
            runner.run_script(known_scripts.START)
Exemple #2
0
def install_remote_dependencies():
    ''' Install dependencies on the remote host. '''
    remote_info('Installing dependencies on the remote')
    if runner.is_script_defined(known_scripts.INSTALL_REMOTE):
        runner.run_script(known_scripts.INSTALL_REMOTE)
    else:
        runner.run_script(known_scripts.INSTALL)
Exemple #3
0
def install_remote_dependencies(commit, current_path, smart_install):
    ''' Install dependencies on the remote host. '''
    history = buildman.load_history()
    prev_build = buildman.get_prev_build_info(history)

    # Check if the installation could be skipped (smart_install).
    can_skip_installation = (
        smart_install and
        prev_build and
        not has_updated_dependencies(prev_build['commit'], commit)
    )

    # Smart install - copy the node_modules directory from the previous deployment
    # if it's usable (no dependencies or package manager files have changed).
    if can_skip_installation:
        runner.run(
            'cp -R {src} {dest}'.format(
                src=os.path.join(prev_build['path'], 'node_modules'),
                dest=os.path.join(current_path, 'node_modules')
            )
        )
        remote_info('Skipping installation - No change in dependencies.')
        return

    # Install dependencies on the remote.
    with cd(current_path):
        remote_info('Installing dependencies on the remote')
        runner.run_script_safely(known_scripts.PRE_INSTALL)

        if runner.is_script_defined(known_scripts.INSTALL_REMOTE):
            runner.run_script_safely(known_scripts.PRE_INSTALL_REMOTE)
            runner.run_script(known_scripts.INSTALL_REMOTE)
            runner.run_script_safely(known_scripts.POST_INSTALL_REMOTE)
        else:
            runner.run_script_safely(known_scripts.INSTALL)

        runner.run_script_safely(known_scripts.POST_INSTALL)