Tag Archives: tech

Using javan/whenever on Engine Yard Cloud

via Deploy Hook

UPDATE 4/10/2013: Updating these instructions to use bundle exec, per chintan/Nic Pillinger

If you want your crontab updated by whenever on deploy, make a file named deploy/before_restart.rb and stick this in it (make sure you replace ‘yourAppNameHere’, derp):

@rails_env = node[:environment][:framework_env]
run "cd #{release_path}; bundle exec whenever --set environment=#{@rails_env}; bundle exec whenever --update-crontab 'yourAppNameHere'"

This is called a ‘deploy hook’ and here’s more info.

via Deploy Hook using Binstubs

Since Engine Yard automatically installs your binstubs, you could also replace “bundle exec whenever” with “ey_bundler_binstubs/whenever”. If you want to be able to run “bin/whenever” you’ll have to symlink to ey_bundler_binstubs – but remember it’s in the current deploy directory, so you’ll have to do this per-deploy – which means you could stick this in the same before_restart.rb file (obviously it would need to be above the whenever line):

run "ln -nfs #{release_path}/ey_bundler_binstubs #{release_path}/bin"
@rails_env = node[:environment][:framework_env]
run "cd #{release_path}; bin/whenever --set environment=#{@rails_env}; bin/whenever --update-crontab 'yourAppNameHere'"

Note for Utility Instances

Desi McAdam was kind enough to note: “Secondary note for your readers just in case they need a reminder. If you only want this to run on a util server be sure to wrap the above deploy hook stuff with current_role == ‘util’.”

via Custom Chef Recipes

UPDATE 4.17.2012: If you’re on EY and not using custom chef recipes, you should start. A whenever recipe has been written and is detailed here. Info on how to start using custom chef recipes is here. It’s not so bad, really. One gotcha: your “appname” in the recipe is not your rails application name, but your EY application name – these can be different things!