capistrano

Capistrano tips and tricks

cap deploy:upload - quickly replace a few files only

If you only need to update one or two files (usually when you have to do a minimal change) you can also use deploy:upload

// example

cap production deploy:upload FILES=app/models/user.rb,app/models/collective.rb

// restart application (sometimes not even required (images, css, js)

cap production deploy:restart

Don't abuse this since it's very easy to end up with an inconsistent codebase if you forget a file!

cap shell - a parallel ssh shell for all production servers

SSH on speed.:

[$ cap production shell # cap> on web03.dmz.xxx.org,web04.dmz.xxx.org touch /tmp/hello_world # cap> on web03.dmz.xxx.org,web04.dmz.xxx.org !deploy:restart ** [out :: web04.dmz.xxx.org] stopping port 8100 ** [out :: web03.dmz.xxx.org] stopping port 8100 ** [out :: web04.dmz.xxx.org] stopping port 8101 [...] # # with role: # cap> with app chown -R xyz /var/lib/xxxx/current/tmp

upload files

If there is only 1 file and you know what you're doing, you can use capistrano to upload a file from your local checkout on dev01. Don't forget to get the latest version of the code with 'git pull'

git pull cap production deploy:upload FILES=app/controllers/donations_controller.rb