Tuesday, August 11, 2009

Easily manage multiple apps

Sometimes you want to run a command on each of your rails apps. i.e. git pull or rake db:migrate

A simple ruby script can handle that:



PATH = '/mnt/apps'

Dir.glob("#{PATH}/*").each do |dir|
puts "(in #{dir})"
ARGV.each { |cmd| system(cmd) }

This script iterates each folder under "/mnt/apps" directory, goes into that directory and executes each command.

you can run it like so:

./each-app.rb 'git pull' 'rake db:migrate'

just dont forget to

chmod +x each-app.rb

happy hacking

No comments: