The Scoop

  • Home
  • Projects
  • About The Scoop
  • Fixing Journalism
  • Medill Links
  • Departments
    • API
    • Apple
    • Asides
    • Broadcast
    • Campaign Finance
    • Car Tools
    • Data
    • DIY
    • django
    • Fed Data
    • FOIA
    • General
    • IRE
    • Journalism
    • Local Data
    • Mapping
    • Miscellany
    • NonGov Data
    • Online
    • Paper Trail
    • Presentations
    • Public Records
    • Python
    • Rails
    • SLA
    • Social Network Analysis
    • Sports
    • State Data
    • Teaching
    • Work
    • XML
  • Subscribe via RSS

Deploying Django with Fabric

December 2nd, 2008  |  Published in django  |  4 Comments

Since I started using Ruby and Rails last year, I’ve come to know and like Capistrano, the deployment utility that makes pushing code and databases around a lot easier than it has to be. We use Capistrano for internal and external deploys at the Times, and it’s a pretty robust tool. While working on Fumblerooski and some other projects, I was looking for a Python-based deployment utility (although, to be fair, Capistrano can be used with just about anything), and I came upon Fabric.

If you haven’t heard of Capistrano, it and similar utilities save you the trouble of typing a series of commands to login to remote servers, update your code, bounce Apache, clean up files, etc. You put all that stuff into a single file that just runs those tasks when you need them. If you have an app that you’re regularly updating, it’s a godsend.

If you’ve used Capistrano before, Fabric is pretty similar in terms of its philosophy; there’s a fabfile in your project (like a capfile for Capistrano) that contains the configuration details and your commands for deploying code, restarting servers and the like. What I like about Fabric is that it makes virtually no assumptions about what you want to do. It doesn’t default to Subversion, or git, as a VCS. It doesn’t assume much of anything, which can be a little daunting if you’re used to a bit of code generation.

But that’s actually a good thing, because you end up writing fabfiles that only contain the stuff you need to have and nothing else. There’s a Django app that ties Fabric more tightly to Django’s manage.py utility, but I’m not sure I see the need for it. Without it, you type something like “fab deploy” instead of “python manage.py fab deploy”. But it’s there.

One thing I’d like to see from Fabric is better handling for sudo tasks on remote servers. This has been raised on the mailing list, and hopefully it gets resolved soon. Otherwise I’m really enjoying its simplicity and will use it for my Django apps going forward.

Responses

Feed Trackback Address
  1. Ben says:

    December 2nd, 2008 at 11:33 pm (#)

    I also use and enjoy fabric, without the django pluging, which I haven’t tried. I’ve also never tried Capistrano with Django, so I don’t have any criticism. It might be awesome.

    But the thing I like most about fabric is how I can easily customize a variety of upkeep and monitoring tasks in addition to revision control on application code. Plus it’s really easy for my simple brain to read.

    FWIW, my chosen shazam line is:

    $ fab prod deploy reboot

  2. Nick Sergeant says:

    December 3rd, 2008 at 11:39 am (#)

    Fabric is great, and the developers are even more so. They’ve routinely answered questions and even turned around quick feature improvements in response to issues on the mailing list. Kudos to them.

    I wrote some quick fab code to interact with MySQL database dumping and loading, etc, since that’s the most frequent beast I struggle with. I wrote it up in a quick blog post here:

    http://nicksergeant.com/blog/programming/developing-and-deploying-applications-fabric-and-subversion

    Happy coding!

  3. Deploying Django with Mercurial, Fab and Nginx « Stream Hacker says:

    April 26th, 2009 at 2:10 pm (#)

    [...] is a fab command that can run remote and sudo commands on one or more remote hosts. So let’s deploy Django using fab. Here’s an example fabfile with 2 commands: restart and nginx. These commands should only be [...]

  4. Deploying Django with Mercurial, Fab and Nginx « streamhacker.com says:

    January 24th, 2010 at 10:04 pm (#)

    [...] is a fab command that can run remote and sudo commands on one or more remote hosts. So let’s deploy Django using fab. Here’s an example fabfile with 2 commands: restart and nginx. These commands should only be [...]

Leave a Response

Recent Comments

  • Dave Stanton on A GitHub for Data?
  • Jessica Baumgart on How APIs Help the Newsroom
  • Bookmarks van juli 7th tot juli 14th | .: zerocontent - Blog :. on How APIs Help the Newsroom
  • Reporting with Data: How the New York Times Uses APIs on How APIs Help the Newsroom
  • Brad B on Six Reasons To Look Past Caspio

Recent Posts

  • A GitHub for Data?
  • How APIs Help the Newsroom
  • Big Numbers, Low Impact
  • Using the NYT Congress API with … Excel?
  • An Even Better CAR Conference?

Linking Out

  • Prop 19 Campaign Contributions - Los Angeles Times
  • Introducing the Open State Project API - Sunlight Labs: Blog
  • Teaching Geo-Spatial Thinking in High School Social Studies
  • NYC's Worst Landlords Watchlist | NYC Public Advocate
  • Chicago Tribune 2009 Illinois School Report Cards
  • 5,800 dead in Ohio still on voter rolls | The Columbus Dispatch
  • Nebraska Cornhuskers football rosters database - Omaha.com
  • offensive politics llc - House Data project
  • Cannibalize Business Development by Popularizing your API - Shaival Shah's Blog
  • Using the DocumentCloud API
  • Centralized logging for fun and profit! | Revolution Systems
  • AP IMPACT: Katrina a tale of SBA failure - Yahoo! News
  • RaceTracker is Up-To-Date for Today's Primaries - Blog - OpenCongress
  • Campaign cash: what interest groups are spending on 2010 midterm elections (washingtonpost.com)
  • Using Freebase Gridworks to Create Linked Data | Jeni's Musings


©2010 The Scoop
Powered by WordPress using the Gridline Lite theme by Graph Paper Press.