我在后台用Clockworkd运行时钟。如果我只运行clockwork,它就会成功地执行rake命令。如果我通过clockworkd运行它,它会产生一个错误。我不知道为什么不管用。如有任何意见/建议,将不胜感激。
启动时钟
RAILS_ENV=production clockworkd -c lib/clock.rb start --log错误
I, [2013-09-05T17:53:01.035923 #2580] INFO -- : Triggering 'Get Updates'
rake aborted!
No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb)
/Users/lukesmith/.rvm/gems/ruby-1.9.3-p327/gems/rake-10.1.0/lib/rake/application.rb:632:in `raw_load_rakefile'
/Users/lukesmith/.rvm/gems/ruby-1.9.3-p327/gems/rake-10.1.0/lib/rake/application.rb:94:in `block in load_rakefile'
/Users/lukesmith/.rvm/gems/ruby-1.9.3-p327/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/Users/lukesmith/.rvm/gems/ruby-1.9.3-p327/gems/rake-10.1.0/lib/rake/application.rb:93:in `load_rakefile'
/Users/lukesmith/.rvm/gems/ruby-1.9.3-p327/gems/rake-10.1.0/lib/rake/application.rb:77:in `block in run'
/Users/lukesmith/.rvm/gems/ruby-1.9.3-p327/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/Users/lukesmith/.rvm/gems/ruby-1.9.3-p327/gems/rake-10.1.0/lib/rake/application.rb:75:in `run'
/Users/lukesmith/.rvm/gems/ruby-1.9.3-p327/gems/rake-10.1.0/bin/rake:33:in `<top (required)>'
/Users/lukesmith/.rvm/gems/ruby-1.9.3-p327/bin/rake:23:in `load'
/Users/lukesmith/.rvm/gems/ruby-1.9.3-p327/bin/rake:23:in `<main>'clock.rb
require 'clockwork'
require File.expand_path('../../config/boot', __FILE__)
require File.expand_path('../../config/environment', __FILE__)
include Clockwork
handler do |job|
puts "Running #{job}"
end
every(1.hour, 'Get Updates') { `rake get_updates` }发布于 2013-09-05 17:11:26
运行rake get_updates任务的进程可能不在Rakefile所在的工作目录中。
您可以使用Dir.chdir '/dir/containing/Rakefile/',或者使用-f选项显式地将路径传递给Rakefile:
every(1.hour, 'Get Updates') do
Dir.chdir '/dir/containing/Rakefile/'
`rake get_updates`
endhttps://stackoverflow.com/questions/18641999
复制相似问题