writing cron tab for an environment other than production

55 views
Skip to first unread message

aurels

unread,
Oct 27, 2009, 9:50:57 AM10/27/09
to Whenever Gem
Hi,

I'm trying to use whenever with a multistage setup (staging +
production). Here is my cap task:

namespace :deploy do
desc "Write the crontab file"
task :update_crontab, :roles => :db do
run "cd #{current_path} && whenever --write-crontab #{application}
_#{stage}"
end
end

I've named the task-set according to the app name and the current
stage. The problem is that it always runs in production, even if
staging is the current environment. I.e., aways outputs commands of
this kind:

(cd /.../awsome-app/releases/42 && RAILS_ENV=production /usr/bin/env
rake app:awsome_cron)

Is there a config option or a way to force the RAILS_ENV var to be set
at #{stage} ?

Thanks is advance,

Aurélien

Javan Makhmali

unread,
Oct 27, 2009, 10:08:56 AM10/27/09
to whenev...@googlegroups.com
You sure can, here's a bit more info: http://wiki.github.com/javan/whenever/setting-variables-on-the-fly

Basically you'd do something like this:

run "cd #{current_path} && whenever --set environment=#{stage} --write-
crontab #{application}_#{stage}"


Javan

aurels

unread,
Oct 27, 2009, 10:43:54 AM10/27/09
to Whenever Gem
Thanks, that's exactly what I was trying to do ;)
Keep up the good work.

Aurélien
http://aurelien.malisart.be
http://en.agilitic.com
Reply all
Reply to author
Forward
0 new messages