コード例 #1
0
ファイル: fabfile.py プロジェクト: richartl/rokoloca-api
def sync_files():
    """
    Sync modified files and establish necessary permissions in selected environment.
    """
    require('group', 'public_dir')

    print white("Uploading code to server...", bold=True)
    ursync_project(
        local_dir='./',
        remote_dir=env.public_dir,
        exclude=env.exclude,
        delete=True,
        default_opts='-chrtvzP'
    )
コード例 #2
0
ファイル: fabfile.py プロジェクト: dgamboaestrada/chuy
def sync_files(delete=False):
    """
    Sync modified files and establish necessary permissions in selected environment.
    """
    require('group', 'public_dir', 'src', 'exclude')

    print white("Uploading code to server...", bold=True)
    ursync_project(
        local_dir="'./{src}/'".format(**env),
        remote_dir=env.public_dir,
        exclude=env.exclude,
        delete=delete,
        default_opts='-chrtvzP'
    )
    print white("Estableciendo permisos...", bold=True)
    run('chgrp -R {0} {1}'.format(env.group, env.public_dir))

    print green(u'Successfully sync.')
コード例 #3
0
ファイル: fabfile.py プロジェクト: mrchucu1/chuy
def sync_files(delete=False):
    """
    Sync modified files and establish necessary permissions in selected environment.
    """
    require('group', 'public_dir', 'src', 'exclude')

    print white("Uploading code to server...", bold=True)
    ursync_project(
        local_dir="'./{src}/'".format(**env),
        remote_dir=env.public_dir,
        exclude=env.exclude,
        delete=delete,
        default_opts='-chrtvzP'
    )
    print white("Estableciendo permisos...", bold=True)
    run('chgrp -R {0} {1}'.format(env.group, env.public_dir))

    print green(u'Successfully sync.')
コード例 #4
0
ファイル: fabfile.py プロジェクト: rodrisan/chuy
def sync_files(delete=False):
    """
    Sync modified files and establish necessary permissions in selected environment.
    """
    require("group", "public_dir", "src", "exclude")

    print white("Uploading code to server...", bold=True)
    ursync_project(
        local_dir="./{src}/".format(**env),
        remote_dir=env.public_dir,
        exclude=env.exclude,
        delete=delete,
        default_opts="-chrtvzP",
    )
    print white("Estableciendo permisos...", bold=True)
    run("chgrp -R {0} {1}".format(env.group, env.public_dir))

    print green(u"Successfully sync.")
コード例 #5
0
ファイル: fabfile.py プロジェクト: shrmoud/schoolapp
def certs(git_ref):
    """
    Update certs in server.
    """
    require('hosts', 'user', 'site_dir', 'django_settings')

    # Retrives git reference metadata and creates a temp directory with the
    # contents resulting of applying a ``git archive`` command.
    message = white('Creating git archive from {0}'.format(git_ref), bold=True)
    with cmd_msg(message):
        repo = ulocal('basename `git rev-parse --show-toplevel`', capture=True)
        commit = ulocal('git rev-parse --short {0}'.format(git_ref),
                        capture=True)

        tmp_dir = '/tmp/blob-{0}-{1}/'.format(repo, commit)

        ulocal('rm -fr {0}'.format(tmp_dir))
        ulocal('mkdir {0}'.format(tmp_dir))

        ulocal('git archive {0} ./certs | tar -xC {1} --strip 1'.format(
            commit, tmp_dir))

    # Uploads the code of the temp directory to the host with rsync telling
    # that it must delete old files in the server, upload deltas by checking
    # file checksums recursivelly in a zipped way; changing the file
    # permissions to allow read, write and execution to the owner, read and
    # execution to the group and no permissions for any other user.
    with cmd_msg(white('Uploading code to server...', bold=True)):
        ursync_project(local_dir=tmp_dir,
                       remote_dir=env.certs_dir,
                       delete=True,
                       default_opts='-chrtvzP',
                       extra_opts='--chmod=750',
                       exclude=["*.pyc", "env/", "cover/"])
    # Clean the temporary snapshot files that was just deployed to the host
    message = white('Cleaning up...', bold=True)
    with cmd_msg(message):
        ulocal('rm -fr {0}'.format(tmp_dir))

    puts(green(SUCCESS_ART), show_prefix=False)
    puts(white('Code from {0} was succesfully deployed to host {1}'.format(
        git_ref, ', '.join(env.hosts)),
               bold=True),
         show_prefix=False)
コード例 #6
0
def sync_files():
    """
    Sync modified files and establish necessary permissions in selected environment.
    """
    require('group', 'wpworkflow_dir', 'public_dir')

    print white("Uploading code to server...", bold=True)
    ursync_project(local_dir='./src/',
                   remote_dir=env.wpworkflow_dir,
                   delete=True,
                   default_opts='-chrtvzP')

    print white("Estableciendo permisos...", bold=True)
    run('chmod -R o-rwx {0}'.format(env.wpworkflow_dir))
    run('chmod -R o-rwx {0}'.format(env.public_dir))
    run('chgrp -R {0} {1}'.format(env.group, env.wpworkflow_dir))
    run('chgrp -R {0} {1}'.format(env.group, env.public_dir))

    print green(u'Successfully sync.')
コード例 #7
0
def sync_files():
    """
    Sync modified files and establish necessary permissions in selected environment.
    """
    require('group', 'wpworkflow_dir', 'public_dir')

    print white("Uploading code to server...", bold=True)
    ursync_project(
        local_dir='./src/',
        remote_dir=env.wpworkflow_dir,
        delete=True,
        default_opts='-chrtvzP'
    )

    print white("Estableciendo permisos...", bold=True)
    run('chmod -R o-rwx {0}'.format(env.wpworkflow_dir))
    run('chmod -R o-rwx {0}'.format(env.public_dir))
    run('chgrp -R {0} {1}'.format(env.group, env.wpworkflow_dir))
    run('chgrp -R {0} {1}'.format(env.group, env.public_dir))

    print green(u'Successfully sync.')
コード例 #8
0
def maintenance(state):
    """
    Sets maintenance mode 'on' or 'off' on the server.
    """
    require('maintenance_dir')

    if boolean(state):
        ursync_project(
            local_dir='./maintenance/',
            remote_dir=env.maintenance_dir,
            delete=True,
            default_opts='-chrtvzP',
            extra_opts='--chmod=750',
        )

        with cd(env.maintenance_dir):
            run('chgrp -R {0} .'.format(env.group))

    else:
        with cd(env.maintenance_dir):
            run('rm -rf ./*')
コード例 #9
0
ファイル: fabfile.py プロジェクト: jualjiman/finanzas
def deploy(git_ref, upgrade=False):
    """
    Deploy the code of the given git reference to the previously selected
    environment.
    Pass ``upgrade=True`` to upgrade the versions of the already installed
    project requirements (with pip).
    """
    require('hosts', 'user', 'group', 'site_dir', 'django_settings')

    # Retrives git reference metadata and creates a temp directory with the
    # contents resulting of applying a ``git archive`` command.
    message = white('Creating git archive from {0}'.format(git_ref), bold=True)
    with cmd_msg(message):
        repo = ulocal(
            'basename `git rev-parse --show-toplevel`', capture=True)
        commit = ulocal(
            'git rev-parse --short {0}'.format(git_ref), capture=True)
        branch = ulocal(
            'git rev-parse --abbrev-ref HEAD', capture=True)

        tmp_dir = '/tmp/blob-{0}-{1}/'.format(repo, commit)

        ulocal('rm -fr {0}'.format(tmp_dir))
        ulocal('mkdir {0}'.format(tmp_dir))
        ulocal('git archive {0} ./src | tar -xC {1} --strip 1'.format(
            commit, tmp_dir))

    # Uploads the code of the temp directory to the host with rsync telling
    # that it must delete old files in the server, upload deltas by checking
    # file checksums recursivelly in a zipped way; changing the file
    # permissions to allow read, write and execution to the owner, read and
    # execution to the group and no permissions for any other user.
    with cmd_msg(white('Uploading code to server...', bold=True)):
        ursync_project(
            local_dir=tmp_dir,
            remote_dir=env.site_dir,
            delete=True,
            default_opts='-chrtvzP',
            extra_opts='--chmod=750',
            exclude=[
                "*.pyc", "env/",
                "cover/", "*.style",
                "bower_components"
            ]
        )

    # Performs the deployment task, i.e. Install/upgrade project
    # requirements, syncronize and migrate the database changes, collect
    # static files, reload the webserver, etc.
    message = white('Running deployment tasks', bold=True)
    with cmd_msg(message, grouped=True):
        with virtualenv():

            message = white('Installing Python requirements with pip')
            with cmd_msg(message, spaces=2):
                run('pip install -{0}r ./requirements/production.txt'.format(
                    'U' if upgrade else ''))

            message = white('Migrating database')
            with cmd_msg(message, spaces=2):
                run('python manage.py migrate --noinput')

            message = white('Collecting static files')
            with cmd_msg(message, spaces=2):
                run('python manage.py collectstatic --noinput')

            message = white('Setting file permissions')
            with cmd_msg(message, spaces=2):
                run('chgrp -R {0} .'.format(env.group))
                run('chgrp -R {0} ../media'.format(env.group))

            message = white('Restarting webserver')
            with cmd_msg(message, spaces=2):
                run('touch ../reload')

            message = white('Registering deployment')
            with cmd_msg(message, spaces=2):
                register_deployment(commit, branch)

    # Clean the temporary snapshot files that was just deployed to the host
    message = white('Cleaning up...', bold=True)
    with cmd_msg(message):
        ulocal('rm -fr {0}'.format(tmp_dir))

    puts(green(SUCCESS_ART), show_prefix=False)
    puts(white('Code from {0} was succesfully deployed to host {1}'.format(
        git_ref, ', '.join(env.hosts)), bold=True), show_prefix=False)
コード例 #10
0
ファイル: fabfile.py プロジェクト: Fabfm4/Sita-BackEnd
def deploy(git_ref, upgrade=False):
    """Deploy project.

    Deploy the code of the given git reference to the previously selected
    environment.

    Args:
        upgrade(Optional[bool]):
            Pass ``upgrade=True`` to upgrade the versions of the already
            installed project requirements (with pip)
        git_ref(str): name branch you make deploy.

    Example:
        >>>fab environment:vagrant deploy:devel.
    """
    require('hosts', 'user', 'group', 'site_dir', 'django_settings')

    # Retrives git reference metadata and creates a temp directory with the
    # contents resulting of applying a ``git archive`` command.
    message = white('Creating git archive from {0}'.format(git_ref), bold=True)
    with cmd_msg(message):
        repo = ulocal('basename `git rev-parse --show-toplevel`', capture=True)
        commit = ulocal('git rev-parse --short {0}'.format(git_ref),
                        capture=True)
        branch = ulocal('git rev-parse --abbrev-ref HEAD', capture=True)

        tmp_dir = '/tmp/blob-{0}-{1}/'.format(repo, commit)

        ulocal('rm -fr {0}'.format(tmp_dir))
        ulocal('mkdir {0}'.format(tmp_dir))
        ulocal('git archive {0} ./src | tar -xC {1} --strip 1'.format(
            commit, tmp_dir))

    # Uploads the code of the temp directory to the host with rsync telling
    # that it must delete old files in the server, upload deltas by checking
    # file checksums recursivelly in a zipped way; changing the file
    # permissions to allow read, write and execution to the owner, read and
    # execution to the group and no permissions for any other user.
    with cmd_msg(white('Uploading code to server...', bold=True)):
        ursync_project(local_dir=tmp_dir,
                       remote_dir=env.site_dir,
                       delete=True,
                       default_opts='-chrtvzP',
                       extra_opts='--chmod=750',
                       exclude=["*.pyc", "env/", "cover/"])

    # Performs the deployment task, i.e. Install/upgrade project
    # requirements, syncronize and migrate the database changes, collect
    # static files, reload the webserver, etc.
    message = white('Running deployment tasks', bold=True)
    with cmd_msg(message, grouped=True):
        with virtualenv():

            message = white('Installing Python requirements with pip')
            with cmd_msg(message, spaces=2):
                run('pip install -{0}r ./requirements/production.txt'.format(
                    'U' if upgrade else ''))

            message = white('Migrating database')
            with cmd_msg(message, spaces=2):
                run('python manage.py migrate --noinput')

            message = white('Collecting static files')
            with cmd_msg(message, spaces=2):
                run('python manage.py collectstatic --noinput')

            message = white('Setting file permissions')
            with cmd_msg(message, spaces=2):
                run('chgrp -R {0} .'.format(env.group))
                run('chgrp -R {0} ../media'.format(env.group))

            message = white('Restarting webserver')
            with cmd_msg(message, spaces=2):
                run('touch ../reload')

            message = white('Registering deployment')
            with cmd_msg(message, spaces=2):
                register_deployment(commit, branch)

    # Clean the temporary snapshot files that was just deployed to the host
    message = white('Cleaning up...', bold=True)
    with cmd_msg(message):
        ulocal('rm -fr {0}'.format(tmp_dir))

    puts(green(SUCCESS_ART), show_prefix=False)
    puts(white('Code from {0} was succesfully deployed to host {1}'.format(
        git_ref, ', '.join(env.hosts)),
               bold=True),
         show_prefix=False)
コード例 #11
0
def deploy(git_ref, upgrade=False):
    """
    Deploy the code of the given git reference to the previously selected
    environment.
    Pass ``upgrade=True`` to upgrade the versions of the already installed
    project requirements (with pip).
    """
    require('hosts', 'user', 'group', 'site_dir', 'environment')

    # Retrives git reference metadata and creates a temp directory with the
    # contents resulting of applying a ``git archive`` command.
    message = white('Creating git archive from {0}'.format(git_ref), bold=True)
    with cmd_msg(message):
        repo = ulocal(
            'basename `git rev-parse --show-toplevel`', capture=True)
        commit = ulocal(
            'git rev-parse --short {0}'.format(git_ref), capture=True)

        tmp_dir = '/tmp/blob-{0}-{1}/'.format(repo, commit)

        ulocal('rm -fr {0}'.format(tmp_dir))
        ulocal('mkdir {0}'.format(tmp_dir))
        ulocal('git archive {0} ./src | tar -xC {1} --strip 1'.format(
            commit, tmp_dir))

    # Uploads the code of the temp directory to the host with rsync telling
    # that it must delete old files in the server, upload deltas by checking
    # file checksums recursivelly in a zipped way; changing the file
    # permissions to allow read, write and execution to the owner, read and
    # execution to the group and no permissions for any other user.
    with cmd_msg(white('Uploading code to server...', bold=True)):
        ursync_project(
            local_dir=tmp_dir,
            remote_dir=env.site_dir,
            delete=True,
            default_opts='-chrtvzP',
            extra_opts='--chmod=750',
            exclude=["*.env", "*.lock", "storage/", "vendor/"]
        )

    # Performs the deployment task, i.e. Install/upgrade project
    # requirements, syncronize and migrate the database changes,
    # reload the webserver, etc.
    message = white('Running deployment tasks', bold=True)
    with cmd_msg(message, grouped=True):
        with cd(env.site_dir):

            if upgrade:
                message = white('Update packages with composer')
                with cmd_msg(message, spaces=2):
                    run('composer update')
            else:
                message = white('Installing packages with composer')
                with cmd_msg(message, spaces=2):
                    run('composer install')

            message = white('Maintenance mode ON')
            with cmd_msg(message, spaces=2):
                run('php artisan down')

            message = white('Migrating database')
            with cmd_msg(message, spaces=2):
                run('php artisan migrate --env={0}'.format(env.environment))

            message = white('Setting file permissions')
            with cmd_msg(message, spaces=2):
                run('chgrp -R {0} .'.format(env.group))

            message = white('Maintenance mode OFF')
            with cmd_msg(message, spaces=2):
                run('php artisan up')

    # Clean the temporary snapshot files that was just deployed to the host
    message = white('Cleaning up...', bold=True)
    with cmd_msg(message):
        ulocal('rm -fr {0}'.format(tmp_dir))

    puts(green(SUCCESS_ART), show_prefix=False)
    puts(white('Code from {0} was succesfully deployed to host {1}'.format(
        git_ref, ', '.join(env.hosts)), bold=True), show_prefix=False)
コード例 #12
0
def deploy(git_ref, upgrade=False):
    """
    Deploy the code of the given git reference to the previously selected
    environment.
    Pass ``upgrade=True`` to upgrade the versions of the already installed
    project requirements (with pip).
    """
    require('hosts', 'user', 'group', 'site_dir', 'django_settings')

    # Retrives git reference metadata and creates a temp directory with the
    # contents resulting of applying a ``git archive`` command.
    message = white('Creating git archive from {0}'.format(git_ref), bold=True)
    with cmd_msg(message):
        repo = ulocal('basename `git rev-parse --show-toplevel`', capture=True)
        commit = ulocal('git rev-parse --short {0}'.format(git_ref),
                        capture=True)
        branch = ulocal('git rev-parse --abbrev-ref HEAD', capture=True)

        tmp_dir = '/tmp/blob-{0}-{1}/'.format(repo, commit)

        ulocal('rm -fr {0}'.format(tmp_dir))
        ulocal('mkdir {0}'.format(tmp_dir))
        ulocal('git archive {0} ./src | tar -xC {1} --strip 1'.format(
            commit, tmp_dir))

    # Puts the site into maintenance mode.
    with cmd_msg(white('Enabling maintenance mode', bold=True)):
        maintenance('on')

    # Uploads the code of the temp directory to the host with rsync telling
    # that it must delete old files in the server, upload deltas by checking
    # file checksums recursivelly in a zipped way; changing the file
    # permissions to allow read, write and execution to the owner, read and
    # execution to the group and no permissions for any other user.
    with cmd_msg(white('Uploading code to server', bold=True)):
        ursync_project(local_dir=tmp_dir,
                       remote_dir=env.site_dir,
                       delete=True,
                       default_opts='-chrtvzP',
                       extra_opts='--chmod=750',
                       exclude=[
                           "*.pyc",
                           "env/",
                           "cover/",
                           "*.style",
                           "bower_components",
                       ])

    # Performs the deployment task, i.e. Install/upgrade project
    # requirements, syncronize and migrate the database changes, collect
    # static files, reload the webserver, etc.
    message = white('Running deployment tasks', bold=True)
    with cmd_msg(message, grouped=True):
        with virtualenv():

            message = 'Installing Python requirements with pip'
            with cmd_msg(message, spaces=2):
                install_requirements(upgrade=upgrade)

            message = 'Migrating database'
            with cmd_msg(message, spaces=2):
                migrate(noinput=True)

            message = 'Installing bower components'
            with cmd_msg(message, spaces=2):
                bower_install()

            message = 'Collecting static files'
            with cmd_msg(message, spaces=2):
                collectstatic()

            message = 'Setting file permissions'
            with cmd_msg(message, spaces=2):
                run('chgrp -R {0} .'.format(env.group))
                run('chgrp -R {0} ../media'.format(env.group))

            message = 'Restarting webserver'
            with cmd_msg(message, spaces=2):
                run('touch ../reload')

            message = 'Restarting celery workers'
            with cmd_msg(message, spaces=2):
                run('sudo /usr/bin/supervisorctl restart {0}-celeryd'.format(
                    env.user))

            message = 'Registering deployment'
            with cmd_msg(message, spaces=2):
                register_deployment(commit, branch)

    # Disable maintenance mode.
    with cmd_msg(white('Disabling maintenance mode', bold=True)):
        maintenance('off')

    # Clean the temporary snapshot files that was just deployed to the host
    message = white('Cleaning up...', bold=True)
    with cmd_msg(message):
        ulocal('rm -fr {0}'.format(tmp_dir))

    puts(green(SUCCESS_ART), show_prefix=False)
    puts(white('Code from {0} was succesfully deployed to host {1}'.format(
        git_ref, ', '.join(env.hosts)),
               bold=True),
         show_prefix=False)