Skip to content

Commit

Permalink
Updated example fabfile.py with new S3 backup stuff.
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Taylor committed Jan 27, 2011
1 parent 9055c52 commit bc2fdd8
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions examples/fabfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
import os

from django.core import management
import settings
management.setup_environ(settings)
# We have to re-name this to avoid clashes with fabric.api.settings.
import settings as django_settings
management.setup_environ(django_settings)

from fabric.api import *
# This will import every command, you may need to get more selective if
Expand All @@ -29,17 +30,22 @@
# This is used for reloading gunicorn processes after code updates.
# Only needed for gunicorn-related tasks.
env.GUNICORN_PID_PATH = os.path.join(env.REMOTE_CODEBASE_PATH, 'gunicorn.pid')
# S3 bucket for s3cmd to upload DB backups to.
# Only needed for backup_db_to_s3
env.S3_DB_BACKUP_BUCKET = 'db_backups'

# Only needed for those using the ft_backup_db_to_s3 management command.
# Options for configuring the S3 DB backups.
env.S3_DB_BACKUP = {
'BUCKET': 'your_db_backup_bucket',
'AWS_ACCESS_KEY_ID': django_settings.AWS_ACCESS_KEY_ID,
'AWS_SECRET_ACCESS_KEY': django_settings.AWS_SECRET_ACCESS_KEY,
}

def staging():
"""
Sets env.hosts to the sole staging server. No roledefs means that all
deployment tasks get ran on every member of env.hosts.
"""
env.hosts = ['staging.example.org']

def prod():
"""
Set env.roledefs according to our deployment setup. From this, an
Expand All @@ -54,10 +60,10 @@ def prod():
env.roledefs['media_servers'] = ['media1.example.org']
# Postgres servers.
env.roledefs['db_servers'] = ['db1.example.org']

# Combine all of the roles into the env.hosts list.
env.hosts = [host[0] for host in env.roledefs.values()]

def deploy():
"""
Full git deployment. Migrations, reloading gunicorn.
Expand All @@ -74,4 +80,4 @@ def deploy_soft():
Just checkout the latest source, don't reload.
"""
git_pull()
print("--- Soft Deployment complete. ---")
print("--- Soft Deployment complete. ---")

0 comments on commit bc2fdd8

Please sign in to comment.