0

I ma trying to add Whenever gem to my Rails project, I added the gem to the Gemfile

gem "whenever", "~> 0.8.4"

and it was installed without any problems. Then I added a simple task into the generated schedule.rb file:

 set :output, "/home/my_deploy_name/project_name/current/log/cron_log.log"

 every 2.minutes do
   command "/usr/bin/some_great_command"
   runner "MyModel.some_method"
   rake "some:great:rake:task"
   puts "It's working !!!"
 end

and then I added following to the deploy.rb file:

set :whenever_command, "bundle exec whenever"
require "whenever/capistrano"
namespace :deploy do
  desc "Update the crontab file"
  task :update_crontab, :roles => :db do
    run "cd #{latest_release} && whenever --update-crontab #{application}"
  end
end

I've tried to set up latest_release, current_path and release_path, but in all cases always the same output:

*** [err :: IP] sh: 1:
*** [err :: IP] whenever: not found
*** [err :: IP]
...
*** [err :: 54.221.241.111] /usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/rubygems_integration.rb:214:in `block in replace_gem'
*** [err :: IP] :
*** [err :: IP] whenever is not part of the bundle. Add it to Gemfile.
*** [err :: IP] (
*** [err :: IP] Gem::LoadError
*** [err :: IP] )
*** [err :: IP] from /home/my_deploy_name/project_name/shared/bundle/ruby/2.0.0/bin/whenever:22:in `<main>'

How to fix this issue? (I am deploying to Amazon EC2 - ubuntu)

Thanks

user984621
  • 46,344
  • 73
  • 224
  • 412

1 Answers1

1

"Whenever" I ran into this problem...

Just kidding. Actually this has to do with capistrano, not whenever. You are calling the whenever command in the deploy.rb without the bundle context.

run "cd #{latest_release} && whenever --update-crontab #{application}"

try this:

run "cd #{latest_release} && bundle exec whenever --update-crontab #{application}"
awsmsce
  • 187
  • 9