Issue using whenever gem
I am trying to use whenever
gem in my application but I am not able to run rake com开发者_如何学JAVAmand in schedule.rb
.
Error which is throwing up is
/bin/bash: rake: command not found
I am also using bundler so all my gems are freezed into the application.
Is rake in somewhere atypical, like /usr/local/bin? Try adding this to schedule.rb:
env :PATH, '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin'
Try using 'command' instead of rake. My rake is in /usr/local/bin and I can't figure out how to make it work either. So here's an example of a command instead in schedule.rb:
every 5.minutes do
command "cd " + `pwd`.chomp + " && RAILS_ENV=#{environment} /usr/local/bin/rake rakefile:rakemethod"
end
Note you also have to pass in environment in this example. I think you just do it with 'whenever --update_crontab --set environment=beta' when you call schedule.rb.
I have capistrano do it using the capistrano recipes in the whenever gem (see lib dirs under the whenever source). I do have to set whenever_environment in my capistrano deploy script.
whenever could default to production so I'd just play around with it and see. In other words, you may not need the RAILS_ENV=#{environment} if you are only doing this in production. I have several staging environments so I pass in the environment to help out the script.
If only I could specify a different rake directory to get this to work with /usr/local/bin/rake! Anyone help on that front?
精彩评论