Exemplo n.º 1
0
def run_deploy_script(stage, branch):
    ''' Run the deployment script on the remote host. '''
    script_path = get_deploy_dir() + REMOTE_SCRIPT
    init_script_path = get_deploy_dir() + REMOTE_INIT_SCRIPT
    repo_path = get_repo_path()

    # Check if the script exists (with version) on the remote.
    if not fs.exists(script_path):
        with hide('everything'):
            runner.run('mkdir -p ' + repo_path)
            fs.upload(BASE_PATH + '/misc/scripts/init.sh', init_script_path)
            fs.upload(BASE_PATH + '/misc/scripts/remote-source-deploy.sh',
                      script_path)

    env_vars = dict(
        STAGE=stage,
        BRANCH=branch,
        BASE_DIR=get_deploy_dir(),
        INIT_SCRIPT_PATH=init_script_path,
        REPOSITORY_PATH=repo_path,
        REPOSITORY_URL=get_config()['repository_url'],
        SCRIPT_BUILD=runner.get_script_cmd(known_scripts.BUILD),
        SCRIPT_RELOAD=runner.get_script_cmd(known_scripts.RELOAD),
        SCRIPT_INSTALL=runner.get_script_cmd(known_scripts.INSTALL),
        SCRIPT_STATUS_CHECK=runner.get_script_cmd(known_scripts.STATUS_CHECK),
        SCRIPT_PRE_BUILD=runner.get_script_cmd(known_scripts.PRE_BUILD),
        SCRIPT_POST_BUILD=runner.get_script_cmd(known_scripts.POST_BUILD),
        SCRIPT_PRE_INSTALL=runner.get_script_cmd(known_scripts.PRE_INSTALL),
        SCRIPT_POST_INSTALL=runner.get_script_cmd(known_scripts.POST_INSTALL),
        SCRIPT_PRE_DEPLOY=runner.get_script_cmd(known_scripts.PRE_DEPLOY),
        SCRIPT_POST_DEPLOY=runner.get_script_cmd(known_scripts.POST_DEPLOY))

    # Change None to ''
    # TODO: Create a util function map for dictionary
    for k, v in env_vars.iteritems():
        if v is None:
            env_vars[k] = ''

    with hide('running'):
        with shell_env(**env_vars):
            # Run the sync script on the remote
            runner.run('sh ' + script_path)
Exemplo n.º 2
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)
Exemplo n.º 3
0
def get_repo_path():
    ''' Get remote repository path. '''
    return get_deploy_dir()
Exemplo n.º 4
0
def get_repo_path():
    ''' Get remote repository path. '''
    return get_deploy_dir() + REPOSITORY_PATH
Exemplo n.º 5
0
def stop_service():
    ''' Stop the application service. '''
    with cd(buildman.get_deploy_dir()):
        remote_info('Stopping the service.')
        runner.run_script_safely(known_scripts.STOP)
Exemplo n.º 6
0
def reload_service():
    ''' Restart the application service. '''
    with cd(buildman.get_deploy_dir()):
        remote_info('Reloading the service.')
        runner.run_script_safely(known_scripts.RELOAD)