簡體   English   中英

Capistrano +每當寶石:無法部署,“無論何時都不在捆綁包中。 將其添加到Gemfile。 ”

[英]Capistrano + Whenever gem: Cannot deploy, “whenever is not part of the bundle. Add it to Gemfile. ”

我試圖將每當gem添加到我的Rails項目中時,都將gem添加到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)

謝謝

“每當”我遇到這個問題...

開玩笑。 實際上,這與capistrano有關,而不是在任何時候。 您正在不帶捆綁軟件上下文的deploy.rb中調用whenever命令。

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

嘗試這個:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM