Skip to content
This repository has been archived by the owner on Oct 11, 2021. It is now read-only.

Updated fabfile.py - now includes named app bootstrapping, default collectstatic & compress tasks. #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 28 additions & 6 deletions fabfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ def cont(cmd, message):
########## END HELPERS


########## NEW APP CREATION
@task
def create_app(app_name=None):
"""Create a new app, autonamed if name not provided. Usage: fab create_app[:APP_NAME]."""
if app_name:
cont('heroku create %s' % app_name, "Couldn't create the Heroku app, continue anyway?")
else:
cont('heroku create', "Couldn't create the Heroku app, continue anyway?")
########## END APP CREATION


########## DATABASE MANAGEMENT
@task
def syncdb():
Expand Down Expand Up @@ -80,19 +91,28 @@ def collectstatic():
########## END FILE MANAGEMENT


########## HEROKU MANAGEMENT
########## STATIC FILES COMPRESSOR
@task
def bootstrap():
"""Bootstrap your new application with Heroku, preparing it for a production
deployment. This will:
def compress():
"""Collect all static files, and copy them to S3 for production usage."""
local('%(run)s compress' % env)
########## END STATIC FILE COMPRESSOR


- Create a new Heroku application.
########## HEROKU MANAGEMENT
@task
def bootstrap(app_name=None):
"""Bootstrap a new app with Heroku, prep for production deployment. Usage: fab bootstrap[:APP_NAME]
This will:
- Create a new Heroku application, with the `app_name` if specified .
- Install all ``HEROKU_ADDONS``.
- Sync the database.
- Apply all database migrations.
- Initialize New Relic's monitoring add-on.
"""
cont('heroku create', "Couldn't create the Heroku app, continue anyway?")

# cont('heroku create', "Couldn't create the Heroku app, continue anyway?")
create_app(app_name)

for addon in HEROKU_ADDONS:
cont('heroku addons:add %s' % addon,
Expand All @@ -107,6 +127,8 @@ def bootstrap():

syncdb()
migrate()
collectstatic()
compress()

cont('%(run)s newrelic-admin validate-config - stdout' % env,
"Couldn't initialize New Relic, continue anyway?")
Expand Down