Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Started to flesh out the fabfile with code deplots and dependencies.

  • Loading branch information...
commit b2229f07d467a39625ba8c8b248272d34a6a081b 1 parent 51ae746
@jacobian jacobian authored
Showing with 55 additions and 0 deletions.
  1. +55 −0 fabfile.py
View
55 fabfile.py
@@ -1,7 +1,62 @@
+import unipath
from fabric.api import *
+from fabric.contrib import files
+# Fab settings
env.hosts = ['ve.djangoproject.com']
+# Deployment environment paths and settings and such.
+env.deploy_base = unipath.Path('/home/www/djangoproject.com')
+env.virtualenv = env.deploy_base
+env.code_dir = env.deploy_base.child('src')
+env.git_url = 'git://github.com/jacobian/djangoproject.com.git'
+
+# FIXME: make a deploy branch in this repo to deploy against.
+env.default_deploy_ref = 'origin/community_redux'
+
+def deploy():
+ """
+ Full deploy: new code, update dependencies, migrate, and restart services.
+ """
+ deploy_code()
+ update_dependencies()
+ # migrate()
+ # apache("restart")
+ # memcached("restart")
+
+def quick_deploy():
+ """
+ Quick deploy: new code and an in-place reload.
+ """
+ deploy_code()
+ # apache("reload")
+
+def deploy_code(ref=None):
+ """
+ Update code on the servers from Git.
+ """
+ ref = ref or env.default_deploy_ref
+ puts("Deploying %s" % ref)
+ if not files.exists(env.code_dir):
+ sudo('git clone %s %s' % (env.git_url, env.code_dir))
+ with cd(env.code_dir):
+ sudo('git fetch && git reset --hard %s' % ref)
+
+def update_dependencies():
+ """
+ Update dependencies in the virtualenv.
+ """
+ pip = env.virtualenv.child('bin', 'pip')
+ reqs = env.code_dir.child('deploy-requirements.txt')
+ sudo('%s -q install -r %s' % (pip, reqs))
+
+def _managepy(cmd, site='www'):
+ """
+ Helper: run a management command remotely.
+ """
+ django_admin = env.virtualenv.child('bin', 'django-admin.py')
+
+
def copy_db():
"""
Copy the production DB locally for testing.
Please sign in to comment.
Something went wrong with that request. Please try again.