I'm running clockwork in the background using Clockworkd. If I just run clockwork, it executes the rake command successfully. If I run it via clockworkd, it produces an error. I'm not sure why it isn't working. Any advice / suggestions would be appreciated.
Starting clockworkd
RAILS_ENV=production clockworkd -c lib/clock.rb start --log
The error
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` }
The process running your
rake get_updates
task may not be in the same working directory as your Rakefile is located.You could either
Dir.chdir '/dir/containing/Rakefile/'
, or else explicitly pass the path to the Rakefile using the-f
option: