我的 Rails 应用程序中有一个事件模型:
class Event < ApplicationRecord
...
end
我正在时钟测功机上运行一个时钟进程,它有
require_relative 'boot'
require_relative 'environment'
require 'clockwork'
module Clockwork
every(10.seconds, 'xyz') do
Resque.enqueue(.......)
end
every(2.seconds, '.....') do
Resque.enqueue(.......)
end
end
此clock.rb 文件有一个以给定节奏调用的resque 作业。当我在本地单独的终端中运行发条和排队时它工作正常但是当我在heroku上部署它时它失败了,因为我试图在我的clock.rb中需要environment.rb文件(我试图在heroku上部署而不需要环境但它在 Clockwork 模块中引发了其他问题)。我不明白的部分是为什么它只是为 event.rb 失败?如果它在heroku上失败了,它也应该在本地失败。
错误看起来像:
2017-06-02T06:25:24.578369+00:00 app[clock.1]: /app/app/models/event.rb:1:in `<top (required)>': superclass mismatch for class Event (TypeError)
2017-06-02T06:25:24.578383+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.3/lib/active_support/dependencies.rb:293:in `require'
2017-06-02T06:25:24.578384+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.3/lib/active_support/dependencies.rb:293:in `block in require'
2017-06-02T06:25:24.578385+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.3/lib/active_support/dependencies.rb:259:in `load_dependency'
2017-06-02T06:25:24.578385+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.3/lib/active_support/dependencies.rb:293:in `require'
2017-06-02T06:25:24.578389+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.3/lib/active_support/dependencies.rb:380:in `block in require_or_load'
2017-06-02T06:25:24.578389+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.3/lib/active_support/dependencies.rb:37:in `block in load_interlock'
2017-06-02T06:25:24.578390+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.3/lib/active_support/dependencies/interlock.rb:12:in `block in loading'
2017-06-02T06:25:24.578391+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.3/lib/active_support/concurrency/share_lock.rb:150:in `exclusive'
2017-06-02T06:25:24.578392+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.3/lib/active_support/dependencies/interlock.rb:11:in `loading'
2017-06-02T06:25:24.578393+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.3/lib/active_support/dependencies.rb:37:in `load_interlock'
2017-06-02T06:25:24.578393+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.3/lib/active_support/dependencies.rb:358:in `require_or_load'
2017-06-02T06:25:24.578397+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.3/lib/active_support/dependencies.rb:336:in `depend_on'
2017-06-02T06:25:24.578398+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.3/lib/active_support/dependencies.rb:252:in `require_dependency'
2017-06-02T06:25:24.578399+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.0.3/lib/rails/engine.rb:476:in `block (2 levels) in eager_load!'
2017-06-02T06:25:24.578400+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.0.3/lib/rails/engine.rb:475:in `each'
2017-06-02T06:25:24.578400+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.0.3/lib/rails/engine.rb:475:in `block in eager_load!'
2017-06-02T06:25:24.578401+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.0.3/lib/rails/engine.rb:473:in `each'
2017-06-02T06:25:24.578402+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.0.3/lib/rails/engine.rb:473:in `eager_load!'
2017-06-02T06:25:24.578402+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.0.3/lib/rails/engine.rb:354:in `eager_load!'
2017-06-02T06:25:24.578403+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.0.3/lib/rails/application/finisher.rb:59:in `each'
2017-06-02T06:25:24.578404+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.0.3/lib/rails/application/finisher.rb:59:in `block in <module:Finisher>'
2017-06-02T06:25:24.578404+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.0.3/lib/rails/initializable.rb:30:in `instance_exec'
2017-06-02T06:25:24.578405+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.0.3/lib/rails/initializable.rb:30:in `run'
2017-06-02T06:25:24.578405+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.0.3/lib/rails/initializable.rb:55:in `block in run_initializers'
2017-06-02T06:25:24.578406+00:00 app[clock.1]: from /app/vendor/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:228:in `block in tsort_each'
2017-06-02T06:25:24.578407+00:00 app[clock.1]: from /app/vendor/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
2017-06-02T06:25:24.578407+00:00 app[clock.1]: from /app/vendor/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:431:in `each_strongly_connected_component_from'
2017-06-02T06:25:24.578408+00:00 app[clock.1]: from /app/vendor/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:349:in `block in each_strongly_connected_component'
2017-06-02T06:25:24.578410+00:00 app[clock.1]: from /app/vendor/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:347:in `each'
2017-06-02T06:25:24.578411+00:00 app[clock.1]: from /app/vendor/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:347:in `call'
2017-06-02T06:25:24.578411+00:00 app[clock.1]: from /app/vendor/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:347:in `each_strongly_connected_component'
2017-06-02T06:25:24.578412+00:00 app[clock.1]: from /app/vendor/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:226:in `tsort_each'
2017-06-02T06:25:24.578413+00:00 app[clock.1]: from /app/vendor/ruby-2.4.0/lib/ruby/2.4.0/tsort.rb:205:in `tsort_each'
2017-06-02T06:25:24.578414+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.0.3/lib/rails/initializable.rb:54:in `run_initializers'
2017-06-02T06:25:24.578414+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.0.3/lib/rails/application.rb:352:in `initialize!'
2017-06-02T06:25:24.578416+00:00 app[clock.1]: from /app/config/environment.rb:5:in `<top (required)>'
2017-06-02T06:25:24.578417+00:00 app[clock.1]: from /app/config/clock.rb:2:in `require_relative'
2017-06-02T06:25:24.578417+00:00 app[clock.1]: from /app/config/clock.rb:2:in `<top (required)>'
2017-06-02T06:25:24.578420+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/clockwork-0.2.4/bin/clockwork:13:in `require'
2017-06-02T06:25:24.578421+00:00 app[clock.1]: from /app/vendor/bundle/ruby/2.4.0/gems/clockwork-0.2.4/bin/clockwork:13:in `<top (required)>'
2017-06-02T06:25:24.578421+00:00 app[clock.1]: from /app/vendor/bundle/bin/clockwork:17:in `load'
2017-06-02T06:25:24.578422+00:00 app[clock.1]: from /app/vendor/bundle/bin/clockwork:17:in `<main>'