What's New in Edge Rails: An Interactive Capistrano Shell

Posted by ryan
at 6:31 AM on Monday, September 11, 2006

This utility comes with several warnings about its experimental state and unknown future – but we’re not going to let that damper our inquisitiveness, are we? Introducing a way to execute capistrano commands from a shell environment (think script/console). So how does this Capistrano shell work?

First, start the capistrano shell w/

cap -v shell

Then enter commands to be executed on your remote environments. (These are mostly from the shell source comments itself)


# Execute on all servers
cap> echo ping

# Execute on specific servers
on myserver1.com,myserver2.com echo ping

# To execute based on roles
with app,db echo ping

# Execute a capistrano task
!deploy

# Execute multiple capistrano tasks
!setup deploy

# Combine all the goodness to execute a task on
# specific servers and roles
on myserver1.com !setup
with app !setup

Why would you want to use this shell? Well, you get the ability to simultaneously manipulate several environments from one shell – and all within the friendly confines of capistrano. You should find the rollback task to be especially comforting…

tags: , ,

Comments

Leave a response

  1. JamisSeptember 20, 2006 @ 10:01 AM
    Thanks for the write-up! Personally, I prefer "cap -v shell" to "rake remote:shell", since it keeps the verbosity down. In fact, I've generally taken to preferring the use of 'cap' directly, rather than via rake. Fewer keystrokes!
  2. Ryan DaigleSeptember 22, 2006 @ 12:47 PM
    Hey Jamis, I've updated the article - thanks for the tip!
  3. Cliff WellsSeptember 24, 2006 @ 10:54 PM
    I've thought about this for some (very short) time and I truly fail to see how it's useful. Unless you've got dozens of identical servers (in which case you've probably got real management tools), it seems pretty useless. No offense, but really. Nevertheless, I'm ready to admit I'm being short-sighted if someone can show me a real world example of how you'd use this in a real world environment (ping and uptime don't count as interesting or useful).
  4. Cliff WellsSeptember 24, 2006 @ 10:57 PM
    Sorry, should clarify: as a sysadmin tool that is. I keep seeing examples showing it being used for typical Unixy stuff and I don't see why anyone would ever do that.