2017-01-16 31 views
2

我的應用程序後意外keyword_end使用SidekiqSidekiq-Cron後臺作業處理。
兩個Sidekiq和Sidekiq-克朗被包括在我的Gemfile的全局部分寶石,並在我的應用程序的RVM與寶石安裝bundle install語法錯誤,發動Sidekiq

推出首次sidekiqbundle exec sidekiq從我的Rails應用程序的根目錄後,我收到以下錯誤消息,我過去在這裏複製的完整性:

[email protected]:~/workspace/fantasytennis_app (background-jobs)*$ sidekiq 
2017-01-16T09:04:36.460Z 3850 TID-7pc7o INFO: Booting Sidekiq 4.2.7 with redis options {:url=>nil} 
/home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:477:in `load': /home/asarluhi/workspace/fantasytennis_app/app/workers/check_collections_worker.rb:10: syntax error, unexpected keyword_end, expecting end-of-input (SyntaxError) 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:477:in `block in load_file' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:662:in `new_constants_in' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:476:in `load_file' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:375:in `block in require_or_load' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:37:in `block in load_interlock' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies/interlock.rb:12:in `block in loading' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/activesupport-5.0.0.1/lib/active_support/concurrency/share_lock.rb:117:in `exclusive' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies/interlock.rb:11:in `loading' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:37:in `load_interlock' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:358:in `require_or_load' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:511:in `load_missing_constant' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:203:in `const_missing' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/activesupport-5.0.0.1/lib/active_support/inflector/methods.rb:268:in `const_get' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/activesupport-5.0.0.1/lib/active_support/inflector/methods.rb:268:in `block in constantize' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/activesupport-5.0.0.1/lib/active_support/inflector/methods.rb:266:in `each' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/activesupport-5.0.0.1/lib/active_support/inflector/methods.rb:266:in `inject' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/activesupport-5.0.0.1/lib/active_support/inflector/methods.rb:266:in `constantize' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/activesupport-5.0.0.1/lib/active_support/core_ext/string/inflections.rb:66:in `constantize' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/sidekiq-cron-0.4.5/lib/sidekiq/cron/job.rb:304:in `initialize' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/sidekiq-cron-0.4.5/lib/sidekiq/cron/job.rb:186:in `new' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/sidekiq-cron-0.4.5/lib/sidekiq/cron/job.rb:186:in `block in load_from_array' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/sidekiq-cron-0.4.5/lib/sidekiq/cron/job.rb:185:in `each' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/sidekiq-cron-0.4.5/lib/sidekiq/cron/job.rb:185:in `load_from_array' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/sidekiq-cron-0.4.5/lib/sidekiq/cron/job.rb:156:in `load_from_hash' 
    from /home/asarluhi/workspace/fantasytennis_app/config/initializers/sidekiq.rb:5:in `block in <top (required)>' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/sidekiq-4.2.7/lib/sidekiq.rb:73:in `configure_server' 
    from /home/asarluhi/workspace/fantasytennis_app/config/initializers/sidekiq.rb:1:in `<top (required)>' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `load' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `block in load' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `load' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/railties-5.0.0.1/lib/rails/engine.rb:648:in `block in load_config_initializer' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/activesupport-5.0.0.1/lib/active_support/notifications.rb:166:in `instrument' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/railties-5.0.0.1/lib/rails/engine.rb:647:in `load_config_initializer' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/railties-5.0.0.1/lib/rails/engine.rb:612:in `block (2 levels) in <class:Engine>' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/railties-5.0.0.1/lib/rails/engine.rb:611:in `each' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/railties-5.0.0.1/lib/rails/engine.rb:611:in `block in <class:Engine>' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/railties-5.0.0.1/lib/rails/initializable.rb:30:in `instance_exec' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/railties-5.0.0.1/lib/rails/initializable.rb:30:in `run' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/railties-5.0.0.1/lib/rails/initializable.rb:55:in `block in run_initializers' 
    from /home/asarluhi/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:228:in `block in tsort_each' 
    from /home/asarluhi/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component' 
    from /home/asarluhi/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from' 
    from /home/asarluhi/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:431:in `each_strongly_connected_component_from' 
    from /home/asarluhi/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:421:in `block in each_strongly_connected_component_from' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/railties-5.0.0.1/lib/rails/initializable.rb:44:in `each' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/railties-5.0.0.1/lib/rails/initializable.rb:44:in `tsort_each_child' 
    from /home/asarluhi/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:415:in `call' 
    from /home/asarluhi/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:415:in `each_strongly_connected_component_from' 
    from /home/asarluhi/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:349:in `block in each_strongly_connected_component' 
    from /home/asarluhi/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:347:in `each' 
    from /home/asarluhi/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:347:in `call' 
    from /home/asarluhi/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:347:in `each_strongly_connected_component' 
    from /home/asarluhi/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:226:in `tsort_each' 
    from /home/asarluhi/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:205:in `tsort_each' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/railties-5.0.0.1/lib/rails/initializable.rb:54:in `run_initializers' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/railties-5.0.0.1/lib/rails/application.rb:352:in `initialize!' 
    from /home/asarluhi/workspace/fantasytennis_app/config/environment.rb:5:in `<top (required)>' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/sidekiq-4.2.7/lib/sidekiq/cli.rb:244:in `require' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/sidekiq-4.2.7/lib/sidekiq/cli.rb:244:in `boot_system' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/sidekiq-4.2.7/lib/sidekiq/cli.rb:50:in `run' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/gems/sidekiq-4.2.7/bin/sidekiq:12:in `<top (required)>' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/bin/sidekiq:23:in `load' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/bin/sidekiq:23:in `<main>' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/bin/ruby_executable_hooks:15:in `eval' 
    from /home/asarluhi/.rvm/gems/[email protected]_app_Rails5.0/bin/ruby_executable_hooks:15:in `<main>' 

我檢查了我的app/workers/check_collections_worker.rb文件,該文件提出了在上面的代碼中的第3行中「意外keyword_end」語法錯誤,但沒有錯誤,因爲你可以看到:

Class CheckCollectionsWorker 
    include Sidekiq::Worker 

    def perform 
     collections = TennisCollection.all 
     collections.each do |collection| 
      collection.update_attribute(:check, false) 
     end 
    end 
end 

Sidekiq加載其職位由上到一個列表containe的底部d在config/schedule.yml。頂部的CheckCollectionsWorker類首先被加載。
我試圖移動到頂部依次在每個作業的內部config/schedule.yml,但對於任何人我不斷收到同樣的「意外keyword_end」錯誤消息。 我確定我的代碼是正確的。 sderr報告的「unexpected_key_end」應該在哪裏(以及如何)。

下面是config/schedule.yml關於收集作業的摘錄:

collection_job: 
    cron: "0 20 * 1-11 1" 
    class: "CheckCollectionsWorker" 
    queue: critical 

我從Sidekiq-Cron GitHub page複製並粘貼config/initializers/sidekiq.rb

Sidekiq.configure_server do |config| 
    schedule_file = "config/schedule.yml" 

    if File.exists?(schedule_file) 
    Sidekiq::Cron::Job.load_from_hash YAML.load_file(schedule_file) 
    end 
end 

config/sidekiq.yml文件的內容如下:

--- 
development: 
    :concurrency: 5 
production: 
    :concurrency: 25 
:queues: 
    - [critical, 2] 
    - default 

我真的不知道這個問題的根源,因爲我在工作人員中檢查了很多次代碼,發現沒有錯誤。

回答

2

您的工人一個錯字。 Class CheckCollectionsWorker應以小寫開頭:class