質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Ruby on Rails 5

Ruby on Rails 5は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Q&A

0回答

2391閲覧

Rails、Active Jobの実装で、Sidekiqの立ち上げがうまくいかない

kyotoinrn

総合スコア23

Ruby on Rails 5

Ruby on Rails 5は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

0グッド

0クリップ

投稿2019/01/26 11:38

編集2019/01/26 12:02

前提・実現したいこと

メールによる認証を非同期処理するため、Active Jobsをいじっているのですが、その過程で、Sidekiqの立ち上げがうまく浮かずこのようなエラーが出ます。どのあたりに問題点があるでしょうか?

NameError: uninitialized constant ActiveJob::QueueAdapters::SidekiqAdapter

発生している問題・エラーメッセージ

/RailsSampleApp$ bundle exec sidekiq -C config/sidekiq.yml -e development 2019-01-26T09:12:22.989Z 2787 TID-oxyppwvqj INFO: Booting Sidekiq 5.2.5 with redis options {:url=>"redis://localhost:6379", :id=>"Sidekiq-server-PID-2787"} m, `$b .ss, $$: .,d$ `$$P,d$P' .,md$P"' ,$$$$$bmmd$$$P^' .d$$$$$$$$$$P' $$^' `"^$$$' ____ _ _ _ _ $: ,$$: / ___|(_) __| | ___| | _(_) __ _ `b :$$ \___ \| |/ _` |/ _ \ |/ / |/ _` | $$: ___) | | (_| | __/ <| | (_| | $$ |____/|_|\__,_|\___|_|\_\_|\__, | .d$$ |_| 2019-01-26T09:12:26.223Z 2787 TID-oxyppwvqj INFO: Running in ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux] 2019-01-26T09:12:26.323Z 2787 TID-oxyppwvqj INFO: See LICENSE and the LGPL-3.0 for licensing details. 2019-01-26T09:12:26.424Z 2787 TID-oxyppwvqj INFO: Upgrade to Sidekiq Pro for more features and support: http://sidekiq.org 2019-01-26T09:12:27.059Z 2787 TID-oxyppwvqj WARN: Sidekiq 6.0 will require Redis 4.0+, you are using Redis v3.0.6 2019-01-26T09:12:27.060Z 2787 TID-oxyppwvqj INFO: Starting processing, hit Ctrl-C to stop 2019-01-26T09:12:27.206Z 2787 TID-oxyqaccyf TestJob JID-2b11dc94b38e933910c6955e INFO: start 2019-01-26T09:12:27.227Z 2787 TID-oxyq52okf TestJob JID-6e6557b79f1c5745c1072c1f INFO: start 2019-01-26T09:12:27.238Z 2787 TID-oxyqacd3r TestJob JID-d385d9ab26e23089fc35954e INFO: start 2019-01-26T09:12:27.258Z 2787 TID-oxyq52okf TestJob JID-6e6557b79f1c5745c1072c1f INFO: fail: 0.03 sec 2019-01-26T09:12:27.260Z 2787 TID-oxyq52onf TestJob JID-e196bab153bd70d7201a6344 INFO: start 2019-01-26T09:12:27.321Z 2787 TID-oxyq52okf WARN: {"context":"Job raised exception","job":{"class":"ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper","wrapped":"TestJob","queue":"default","args":[{"job_class":"TestJob","job_id":"4df7fa48-12e0-4991-9308-5ac6ff4b5197","provider_job_id":null,"queue_name":"default","priority":null,"arguments":[1,2,3],"executions":0,"locale":"en"}],"retry":true,"jid":"6e6557b79f1c5745c1072c1f","created_at":1548493666.2746935,"enqueued_at":1548493666.2749245},"jobstr":"{\"class\":\"ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper\",\"wrapped\":\"TestJob\",\"queue\":\"default\",\"args\":[{\"job_class\":\"TestJob\",\"job_id\":\"4df7fa48-12e0-4991-9308-5ac6ff4b5197\",\"provider_job_id\":null,\"queue_name\":\"default\",\"priority\":null,\"arguments\":[1,2,3],\"executions\":0,\"locale\":\"en\"}],\"retry\":true,\"jid\":\"6e6557b79f1c5745c1072c1f\",\"created_at\":1548493666.2746935,\"enqueued_at\":1548493666.2749245}"} 2019-01-26T09:12:27.333Z 2787 TID-oxyq52okf WARN: NameError: uninitialized constant ActiveJob::QueueAdapters::SidekiqAdapter 2019-01-26T09:12:27.355Z 2787 TID-oxyq52okf WARN: /home/ubuntu0876/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sidekiq-5.2.5/lib/sidekiq/processor.rb:267:in `block in constantize' /home/ubuntu0876/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sidekiq-5.2.5/lib/sidekiq/processor.rb:264:in `each' /home/ubuntu0876/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sidekiq-5.2.5/lib/sidekiq/processor.rb:264:in `inject' /home/ubuntu0876/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sidekiq-5.2.5/lib/sidekiq/processor.rb:264:in `constantize' /home/ubuntu0876/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sidekiq-5.2.5/lib/sidekiq/processor.rb:133:in `block (5 levels) in dispatch' /home/ubuntu0876/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sidekiq-5.2.5/lib/sidekiq/rails.rb:43:in `block in call' /home/ubuntu0876/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.6.1/lib/active_support/execution_wrapper.rb:85:in `wrap'/home/ubuntu0876/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.6.1/lib/active_support/reloader.rb:68:in `block in wrap'/home/ubuntu0876/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.6.1/lib/active_support/execution_wrapper.rb:85:in `wrap'/home/ubuntu0876/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.6.1/lib/active_support/reloader.rb:67:in `wrap' /home/ubuntu0876/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sidekiq-5.2.5/lib/sidekiq/rails.rb:42:in `call' /home/ubuntu0876/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sidekiq-5.2.5/lib/sidekiq/processor.rb:132:in `block (4 levels) in dispatch' /home/ubuntu0876/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sidekiq-5.2.5/lib/sidekiq/processor.rb:243:in `stats' /home/ubuntu0876/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sidekiq-5.2.5/lib/sidekiq/processor.rb:127:in `block (3 levels) in dispatch' /home/ubuntu0876/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sidekiq-5.2.5/lib/sidekiq/job_logger.rb:8:in `call' /home/ubuntu0876/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sidekiq-5.2.5/lib/sidekiq/processor.rb:126:in `block (2 levels) in dispatch' /home/ubuntu0876/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sidekiq-5.2.5/lib/sidekiq/job_retry.rb:73:in `global' /home/ubuntu0876/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sidekiq-5.2.5/lib/sidekiq/processor.rb:125:in `block in dispatch' /home/ubuntu0876/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sidekiq-5.2.5/lib/sidekiq/logging.rb:48:in `with_context' /home/ubuntu0876/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sidekiq-5.2.5/lib/sidekiq/logging.rb:42:in `with_job_hash_context' /home/ubuntu0876/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sidekiq-5.2.5/lib/sidekiq/processor.rb:124:in `dispatch' /home/ubuntu0876/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sidekiq-5.2.5/lib/sidekiq/processor.rb:165:in `process' /home/ubuntu0876/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sidekiq-5.2.5/lib/sidekiq/processor.rb:83:in `process_one' /home/ubuntu0876/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sidekiq-5.2.5/lib/sidekiq/processor.rb:71:in `run' /home/ubuntu0876/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sidekiq-5.2.5/lib/sidekiq/util.rb:16:in `watchdog' /home/ubuntu0876/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sidekiq-5.2.5/lib/sidekiq/util.rb:25:in `block in safe_thread' 2019-01-26T09:12:27.491Z 2787 TID-oxyqaccyf TestJob JID-2b11dc94b38e933910c6955e INFO: done: 0.286 sec 2019-01-26T09:12:27.493Z 2787 TID-oxyqacd3r TestJob JID-d385d9ab26e23089fc35954e INFO: done: 0.255 sec 2019-01-26T09:12:27.494Z 2787 TID-oxyq52onf TestJob JID-e196bab153bd70d7201a6344 INFO: done: 0.235 sec 2019-01-26T09:13:06.907Z 2787 TID-oxyq52odv TestJob JID-6e6557b79f1c5745c1072c1f INFO: start 2019-01-26T09:13:06.912Z 2787 TID-oxyq52odv TestJob JID-6e6557b79f1c5745c1072c1f INFO: done: 0.004 sec

該当のソースコード

$ redis-server

2400:C 26 Jan 17:07:08.768 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf 2400:M 26 Jan 17:07:08.775 * Increased maximum number of open files to 10032 (it was originally set to 1024). _._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 3.0.6 (00000000/0) 64 bit .-`` .-```. ```/ _.,_ ''-._ ( ' , .-` | `, ) Running in standalone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379 | `-._ `._ / _.-' | PID: 2400 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-' 2400:M 26 Jan 17:07:08.786 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128. 2400:M 26 Jan 17:07:08.787 # Server started, Redis version 3.0.62400:M 26 Jan 17:07:08.789 # WARNING overcommit_memory is set to 0!Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then rebootor run the command 'sysctl vm.overcommit_memory=1' for this to take effect.2400:M 26 Jan 17:07:08.790 * The server is now ready to accept connections on port 6379

config/application.rb

module RailsSampleApp class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. config.load_defaults 5.1 # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. # Don't generate system test files. config.generators.system_tests = nil config.read_encrypted_secrets = true config.generators do |g| g.skip_routes true g.stylesheets false g.javascripts false g.helper false end config.active_job.queue_adapter = :sidekiq end end

config/initializers/sidekiq.rb

Sidekiq.configure_server do |config| config.redis = { url: 'redis://localhost:6379' } end Sidekiq.configure_client do |config| config.redis = { url: 'redis://localhost:6379' } end

app/jobs/test_job.rb

class TestJob < ApplicationJob queue_as :default def perform(*args) Rails.logger.debug "#{self.class.name}: ジョブを実行しました (#{args.inspect})" end end

config/sidekiq.yml

:concurrency: 25 :queues: - default - mailers

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問