Last active
December 23, 2015 03:29
-
-
Save mrchilds/6573907 to your computer and use it in GitHub Desktop.
Simple Fabric Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Deploy branch to staging | |
from fabric.api import cd, env, parallel, run, task | |
from fabric.decorators import roles | |
# Define your servers | |
env.roledefs = { | |
'staging-web-servers': ['s-web-01.example.com', | |
's-web-03.example.com', | |
's-web-03.example.com'], | |
'staging-db-servers': ['s-db-01.example.com'], | |
} | |
# Update servers at the same time, e.g. in parallel. | |
@parallel | |
@task | |
@roles('staging-web-servers', 'staging-db-servers') | |
def pull_code_onto_servers(branch): | |
# Path to your code | |
with cd(): | |
# Update your code and pull your branch | |
run('git fetch') | |
run('git checkout remotes/origin/%s' % branch) | |
# Restart any relevant services | |
run("sudo supervisorctl restart gunicorn") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment