I assign a node["instance_role'] attribute for each of my nodes and
only the 'app_master' role runs the migrations, the other app servers
are 'app_slaves'.
So basically you just check what role you are and set the migrate
attribute of the deploy resource. to true or false depending on
whether or not you want it to run migrations. Easy to script around.
There are also callbacks that you put in the app being deployed:
APP_ROOT/deploy/{before_migrate.rb,before_restart.rb,before_symlink.rb}
These ruby files will be called at the appropriate time in the deploy
process and will be passed in the RAILS_ENV(or RACK_ENV,MERB_ENV) and
the role of the instance as ARGV[0] and ARGV[1].
You can write any kind of ruby code in these files to accomplish
whatever you need your hooks to accomplish.
I'd love to see a tarball version of this resource, I already have
git done and I have SVN almost done, tarball would be the final one to
do and I don't forsee wanting to support any further SCM's as I want
to keep this fairly simple.
Cheers-
-Ezra
On Apr 17, 2009, at 10:17 AM, Ian Kallen wrote:
Oh, sweet, that's pretty much what I was imagining. Do you have
plans to support "push" deployment (roll an app tarball, dist out to
servers and shimmy the symlinks) ? Also (rails newbness alert) - are
there race conditions with db migrates when you have a cluster of
machines updating in parallel that risk fubaring the schema? I can
imagine without a global lock asserted by the first cluster member
to start a migration, you could get cluster members stepping on each
other trying to execute migrations in parallel.
thanks!
-Ian
Ezra Zygmuntowicz wrote:
I've written chef deploy resources that handle this. The only
thing not implemented yet is rollback but that will be done soon.
http://github.com/ezmobius/chef-deploy/tree
Cheers-
-Ezra
On Apr 17, 2009, at 9:18 AM, Ian Kallen wrote:
Sorry if this is an FAQ I've overlooked. I'm trying to get my head
around best practices wrt to rails deployment. To manage
deployment/rollback of a rails app to a set of apache/passenger
instances, would you create a recipe that invokes capistrano
tasks, create cookbook that gems up the app, distributes and
installs (how would rollbacks be handled?). I see the rails
cookbook on github but it's not clear what the over all workflow
is - if the rails code is housed in git, how do you specify
"deploy this new revision" or "rollback to that revision"? How are
db migrations handled?
thanks!
-Ian
--
Ian Kallen
blog: What's That Noise?! [Ian Kallen's Weblog]
tweetz: http://twitter.com/spidaman
vox: 415.505.5208
--
Ian Kallen
blog: What's That Noise?! [Ian Kallen's Weblog]
tweetz: http://twitter.com/spidaman
vox: 415.505.5208
Ezra Zygmuntowicz
ez@engineyard.com