2017-01-16 6 views
2

私のアプリケーションでは、バックグラウンドジョブ処理にSidekiqSidekiq-Cronが使用されています。
SidekiqとSidekiq-Cronは私のGemfileのグローバルセクションに宝石として含まれており、私のアプリケーションのrvm gemsetにbundle installでインストールされています。シンタックスエラー、予期しないキーワード_end(Sidekiq起動後)

私のRailsアプリケーションのルートから初めてsidekiqまたはbundle exec sidekiqのために起動した後、私は私が過去万全を期すためにここにコピーし、次のエラーメッセージ受信:

[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によって報告された "予期しないkeyword_end"はどこにあるべきか(そして、そうでなければならない)べきです。私はSidekiq-Cron GitHub pageからconfig/initializers/sidekiq.rbをコピー&ペースト

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

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ファイルの内容は以下の通りです:

以下

は、収集ジョブに関する config/schedule.ymlの抽出物であります
--- 
development: 
    :concurrency: 5 
production: 
    :concurrency: 25 
:queues: 
    - [critical, 2] 
    - default 

私は自分の労働者のコードを何度もチェックしてエラーが見つからなかったので、正直なところ、この問題の原因を知らない。

答えて

2

あなたの作業者にタイプミスがあります。 Class CheckCollectionsWorkerは小文字で始まる必要があります。class

関連する問題