Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sidekiq affecting Celluloid in other gems? #1858

Closed
willfults opened this issue Jul 22, 2014 · 8 comments
Closed

Sidekiq affecting Celluloid in other gems? #1858

willfults opened this issue Jul 22, 2014 · 8 comments

Comments

@willfults
Copy link

Hi,
I have a working Rails 3 app that is using sidekiq & the listen gem - https://github.com/guard/listen

It boots up fine, but when I try to start sidekiq in a non-dev environment I get the following error....

undefined method `level=' for nil:NilClass
/srv/www/app/vendor/bundle/ruby/1.9.1/gems/listen-2.7.9/lib/listen/listener.rb:37:in `initialize'
/srv/www/app/vendor/bundle/ruby/1.9.1/gems/listen-2.7.9/lib/listen.rb:70:in `new'
/srv/www/app/vendor/bundle/ruby/1.9.1/gems/listen-2.7.9/lib/listen.rb:70:in `_add_listener'
/srv/www/app/vendor/bundle/ruby/1.9.1/gems/listen-2.7.9/lib/listen.rb:27:in `to'
/srv/www/app/config/application.rb:108:in `block in <class:Application>'
/srv/www/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:34:in `call'
/srv/www/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:34:in `execute_hook'
/srv/www/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
/srv/www/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:42:in `each'
/srv/www/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
/srv/www/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/application/finisher.rb:59:in `block in <module:Finisher>'
/srv/www/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `instance_exec'
/srv/www/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `run'
/srv/www/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:55:in `block in run_initializers'
/srv/www/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `each'
/srv/www/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `run_initializers'
/srv/www/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/application.rb:136:in `initialize!'
/srv/www/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing'
/srv/www/app/config/environment.rb:5:in `<top (required)>'
/srv/www/app/vendor/bundle/ruby/1.9.1/gems/sidekiq-3.1.4/lib/sidekiq/cli.rb:226:in `require'
/srv/www/app/vendor/bundle/ruby/1.9.1/gems/sidekiq-3.1.4/lib/sidekiq/cli.rb:226:in `boot_system'
/srv/www/app/vendor/bundle/ruby/1.9.1/gems/sidekiq-3.1.4/lib/sidekiq/cli.rb:49:in `run'
/srv/www/app/vendor/bundle/ruby/1.9.1/gems/sidekiq-3.1.4/bin/sidekiq:8:in `<top (required)>'
/srv/www/app/vendor/bundle/ruby/1.9.1/bin/sidekiq:23:in `load'
/srv/www/app/vendor/bundle/ruby/1.9.1/bin/sidekiq:23:in `<main>'
root@ordev01:/srv/www/app# undefined method `level=' for nil:NilClass
> /srv/www/app/vendor/bundle/ruby/1.9.1/gems/listen-2.7.9/lib/listen/listener.rb:37:in `initialize'

If I look at the listener.rb:37 line - https://github.com/guard/listen/blob/master/lib/listen/listener.rb - it has this code...
Celluloid.logger.level = _debug_level

And based on the above stack trace, it seems like it can't find Celluloid. What is strange is if I boot up sidekiq in development mode it's fine. Only qa or great has an issue on my ubuntu 12 box. I'm wondering since sidekiq defaults the logger to nil, does this affect the above code? Is there a work around? Thanks in advance.

@mperham
Copy link
Collaborator

mperham commented Jul 22, 2014

Yeah, that's due to Sidekiq nil'ing out the logger. PRs welcome. I'm not sure why I'm not just setting the level to WARN.

BTW Sidekiq 3 does not support Ruby 1.9.

@tarcieri
Copy link

This is a listen bug. It should check the logger is defined before attempting to change the loglevel.

@willfults
Copy link
Author

Thanks for the quick response! I downgraded my sidekiq to the highest 2.x version since I'm on ruby 1.9 & I added this to sidekiq initializer...
Sidekiq::Logging.logger = Logger.new('sidekiq')
Sidekiq::Logging.logger.level = Logger::WARN

But I'm still getting the same error when I run 'bundle exec sidekiq'. This seems to be reproducible in dev as well. What is the easiest way to bypass this error?

@mperham
Copy link
Collaborator

mperham commented Jul 22, 2014

The first arg is not a String.

Sidekiq::Logging.logger = Logger.new(STDOUT)

@willfults
Copy link
Author

Hmm I'm stumped I tried
Sidekiq::Logging.logger = Logger.new(STDOUT)
Sidekiq::Logging.logger.level = Logger::WARN

and still the same error. I also tried forking the listen gem and modifying the listener.rb file but I have no knowledge of that gem and wasn't able to resolve it.

@tarcieri
Copy link

Try this in listen:

Celluloid.logger.level = _debug_level if Celluloid.logger.respond_to?(:level=)

@seuros
Copy link
Collaborator

seuros commented Jul 22, 2014

Celluloid.logger.try(:level=, _debug_level)

if you are using rails

@willfults
Copy link
Author

I had to remove all the log calls in the listen gem and now the error is not displaying, this is probably not the best thing to do, but I can live without the logs for the listen gem. Thank you all for your comments and for the work on the sidekiq gem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants