views:

39

answers:

1

We're hosting our Ruby on Rails application with the EngineYard App Cloud, which has worked really well for us. They provide a series of deploy call backs (before_restart, after_restart, etc.) which are analogous to Capistrano's callbacks.

We have a series of Rake tasks within our application which maintain various parts of the application. If we add a new business rule to the database, we might need to reload the users' associated business rules, etc.

These are tasks that there's no hard or fast schedule for, but also we don't want to run each and every task on every deploy, because they slow down the deploy process.

Are there any systems which would allow us to define a task to be run on the next deploy, sort of like migrations. The ideal system in my mind would work as follows:

  • We realize that on the next deploy, a task will need to be run
  • We schedule the task via the system
  • On the next deploy, the system see the list of post-deploy tasks -- it notices that the most recent one has not been run on the specific server yet (as in how migrations notate the database when they're run so that only the most recent, unrun migrations are triggered) -- the new task is triggered

Any recommendations on best practices for scheduling these post-deploy tasks and have them fire off unless they've already been run on the server?

Thanks!

+2  A: 

Two approaches come to my mind

  1. Quick/dirty solution...could you just use migrations to do this? Create a Rails migration that fires off the tasks when rake db:migrate is run
  2. Take the same approach as migrations. Create a peer table to the schema_migrations table, and then in your before_symlink.rb (or whereever else) run the tasks that have not been executed yet, and then update the table?
Rob Di Marco
Thanks, Rob. Nice to find you on Stack Overflow. This answer suggestions that using migrations might be the best option (http://stackoverflow.com/questions/3671471) though it does seem a bit dirty. Have you ever seen migration-like functionality used for anything other than the DB? I do like the sound of that...
shedd
I have never seen it done that way. It does seem practical to do it that way, but I am always hesitant to have one thing do something that an independent third party would not expect. I am probably making this too complicated though.
Rob Di Marco