Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- from fabric.api import *
- env.git_remote = 'git@example.com:myapp.git'
- def production():
- """Production server settings"""
- env.settings = 'production'
- env.hosts = ['example.com']
- env.user = 'user'
- def deploy():
- """Deploy the latest version of the site to the server and restart"""
- clone_repo()
- checkout_latest()
- install_requirements()
- symlink_current_release()
- migrate()
- reload()
- def clone_repo():
- """Do initial clone of the git repo"""
- run('if [ ! -d ~/shared/cached-copy ]; then git clone %(git_remote)s ~/shared/cached-copy; fi' % env)
- def checkout_latest():
- """Pull the latest code into the git repo and copy to a timestamped release directory"""
- env.release = time.strftime('%Y%m%d%H%M%S')
- run("cd ~/shared/cached-copy; git pull origin master")
- run('cp -R ~/shared/cached-copy ~/releases/%(release)s; rm -rf ~/releases/%(release)s/.git*' % env)
- def install_requirements():
- """Install the required packages using pip"""
- run('pip install -E ~/ -r ~/releases/%(release)s/requirements.txt' % env)
- def symlink_current_release():
- """Symlink our current release, uploads and settings file"""
- run('cd ~/; ln -nfs ~/releases/%(release)s current' % env)
- run('cd ~/current/usability_manager; ln -nfs ~/shared/db db')
- def migrate():
- """Run our migrations"""
- run('cd ~/current; ~/bin/python manage.py syncdb --noinput')
- def reload():
- """Reload uWSGI"""
- run('kill -HUP $(< ~/shared/pids/uwsgi.pid)')
Add Comment
Please, Sign In to add comment