楼上能否详细说明一下,DelayedJob 怎么重启,为什么不重启就不会运行呢? https://github.com/collectiveidea/delayed_job 这里好像没提到呀。。。
########################################### clock.rb 文件定义如下: require File.expand_path('../../config/boot', FILE) require File.expand_path('../../config/environment', FILE) require 'clockwork' include Clockwork
every(5.seconds, 'Queueing BaseProcessorJob job') { Delayed::Job.enqueue BaseProcessorJob.new }
class BaseProcessorJob def perform raise NotImplementedError end
def error(job, exception) Rails.logger.error "Job failed #{exception}" end end
########################################### Procfile 文件定义如下: web: bundle exec rails server worker: bundle exec rake jobs:work clock: bundle exec clockwork lib/clock.rb
########################################### 通过 foreman start 启动: 13:50:11 web.1 | started with pid 22952 13:50:11 worker.1 | started with pid 22954 13:50:11 clock.1 | started with pid 22956
###########################################
执行时 delayed_jobs.last_error 里的记录:
Job failed to load: uninitialized constant BaseProcessorJob. Handler: "--- !ruby/object:BaseProcessorJob {}\n\n"
/home/evan/.rvm/gems/ruby-1.9.2-p320/gems/delayed_job-3.0.4/lib/delayed/backend/base.rb:87:in rescue in payload_object'
/home/evan/.rvm/gems/ruby-1.9.2-p320/gems/delayed_job-3.0.4/lib/delayed/backend/base.rb:85:in
payload_object'
/home/evan/.rvm/gems/ruby-1.9.2-p320/gems/delayed_job-3.0.4/lib/delayed/backend/base.rb:95:in block in invoke_job'
/home/evan/.rvm/gems/ruby-1.9.2-p320/gems/delayed_job-3.0.4/lib/delayed/lifecycle.rb:60:in
call'
/home/evan/.rvm/gems/ruby-1.9.2-p320/gems/delayed_job-3.0.4/lib/delayed/lifecycle.rb:60:in `block in initialize'
.................................................................