2013-09-29 47 views
0

我是個嘗試添加Whenever gem我的Rails項目,我添加了寶石的Gemfile中Capistrano的+每當寶石:無法部署。「只要是不包的一部分將它添加到Gemfile中」

gem "whenever", "~> 0.8.4" 

並且安裝沒有任何問題。 然後,我添加了一個簡單的任務到生成schedule.rb文件:

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 

,然後我添加以下到deploy.rb文件:

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 

我試圖建立latest_releasecurrent_pathrelease_path,但在所有情況下總是相同的輸出:

*** [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>' 

何要解決這個問題? (我部署到Amazon EC2上 - Ubuntu的)

感謝

回答

1

「每當」 我就遇到了這個問題...

只是開個玩笑。其實這與卡皮斯特拉諾有關,不是每次。您在沒有bundle上下文的情況下調用deploy.rb中的every命令。

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

試試這個:

run "cd #{latest_release} && bundle exec whenever --update-crontab #{application}" 
相關問題