我正在尝试将每当 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_release
,current_path
和release_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)
谢谢