Skip to content

Instantly share code, notes, and snippets.

@tuphamphuong
Created July 22, 2015 08:08
Show Gist options
  • Save tuphamphuong/7889fee819e04ca1808b to your computer and use it in GitHub Desktop.
Save tuphamphuong/7889fee819e04ca1808b to your computer and use it in GitHub Desktop.
A sample of complete fabric deploy file
from config import config
__author__ = 'Tu Pham Phuong'
__create_date__ = '4/24/15'
from fabric.api import *
deploy_dir = '/home/tupp/code/api'
def development():
env.user = 'tupp'
env.hosts = ['api.tupp.me']
def production():
env.user = 'tupp'
env.hosts = ['dev.api.tupp.me']
# Bacup important data
def backup():
pass
# Clean mess existed code & data
def cleanup():
pass
# Creates the required directories, asking to remove them first if they already exist
# Creates environment and install dependencies requirement
def bootstrap():
pass
# Clones the project's code from remote git repository
# Checks out the specified branch, using master if no branch is specified
def update_code():
pass
def run_unittest():
pass
# Run some test after deploy
def run_test():
pass
def stop_service():
pass
def start_service():
pass
def restart_service():
pass
# Calls the chain of deploy function
def deploy():
print("Executing on %s as %s" % (env.host, env.user))
cleanup()
backup()
bootstrap()
update_code()
run_unittest()
restart_service()
run_test()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment