Closed nilbus closed 9 years ago
I think it's related to Rails 4. I just had to reverse your PR for Rails 4 routing support, since it broke Rails 3.x apps. You can see a simple app running in production at https://faye-rails-demo.herokuapp.com/
Okay, thanks for looking into it @jamesotron. I'll see if I can track this down.
I am using Rails 3.2.12 with faye-rails 1.0.8 and experiencing the same problem on heroku:
2013-03-14T08:12:39+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/bundler/gems/faye-rails-ab502a439f27/lib/faye-rails/controller/channel.rb:23:in `monitor': undefined method `bind' for nil:NilClass (NoMethodError)
2013-03-14T08:12:39+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/bundler/gems/faye-rails-ab502a439f27/lib/faye-rails/controller.rb:34:in `instance_eval'
2013-03-14T08:12:39+00:00 app[web.1]: from /app/app/realtime/realtime_mindmaps_controller.rb:3:in `block in <class:RealtimeMindmapsController>'
2013-03-14T08:12:39+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/bundler/gems/faye-rails-ab502a439f27/lib/faye-rails/controller.rb:34:in `channel'
2013-03-14T08:12:39+00:00 app[web.1]: from /app/app/realtime/realtime_mindmaps_controller.rb:2:in `<class:RealtimeMindmapsController>'
2013-03-14T08:12:39+00:00 app[web.1]: from /app/app/realtime/realtime_mindmaps_controller.rb:1:in `<top (required)>'
2013-03-14T08:12:39+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:in `require'
2013-03-14T08:12:39+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:in `block in require'
2013-03-14T08:12:39+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:236:in `load_dependency'
2013-03-14T08:12:39+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:in `require'
2013-03-14T08:12:39+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:359:in `require_or_load'
2013-03-14T08:12:39+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:313:in `depend_on'
2013-03-14T08:12:39+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:225:in `require_dependency'
2013-03-14T08:12:39+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/engine.rb:439:in `block (2 levels) in eager_load!'
2013-03-14T08:12:39+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/engine.rb:438:in `each'
2013-03-14T08:12:39+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/engine.rb:438:in `block in eager_load!'
2013-03-14T08:12:39+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/initializable.rb:54:in `each'
2013-03-14T08:12:39+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/engine.rb:436:in `each'
2013-03-14T08:12:39+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/engine.rb:436:in `eager_load!'
2013-03-14T08:12:39+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/initializable.rb:54:in `run_initializers'
2013-03-14T08:12:39+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/application.rb:136:in `initialize!'
2013-03-14T08:12:39+00:00 app[web.1]: from /app/config/environment.rb:5:in `<top (required)>'
2013-03-14T08:12:39+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
2013-03-14T08:12:39+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
2013-03-14T08:12:39+00:00 app[web.1]: from config.ru:1:in `new'
2013-03-14T08:12:39+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.5.0/lib/rack/adapter/loader.rb:33:in `eval'
2013-03-14T08:12:39+00:00 app[web.1]: from config.ru:1:in `<main>'
2013-03-14T08:12:39+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.5.0/lib/rack/adapter/loader.rb:33:in `load'
2013-03-14T08:12:39+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.5.0/lib/thin/controllers/controller.rb:71:in `start'
2013-03-14T08:12:39+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.5.0/lib/thin/controllers/controller.rb:181:in `load_rackup_config'
2013-03-14T08:12:39+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/bin/thin:19:in `load'
2013-03-14T08:12:39+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/bin/thin:19:in `<main>'
2013-03-14T08:12:39+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/initializable.rb:30:in `run'
2013-03-14T08:12:39+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/initializable.rb:55:in `block in run_initializers'
2013-03-14T08:12:39+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/application/finisher.rb:53:in `block in <module:Finisher>'
2013-03-14T08:12:39+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/initializable.rb:30:in `instance_exec'
2013-03-14T08:12:39+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/railtie/configurable.rb:30:in `method_missing'
2013-03-14T08:12:39+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.5.0/lib/thin/runner.rb:187:in `run_command'
2013-03-14T08:12:39+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.5.0/lib/thin/runner.rb:152:in `run!'
2013-03-14T08:12:39+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/thin-1.5.0/bin/thin:6:in `<top (required)>'
2013-03-14T08:12:39+00:00 app[web.1]: from config.ru:3:in `require'
2013-03-14T08:12:39+00:00 app[web.1]: from config.ru:3:in `block in <main>'
2013-03-14T08:12:40+00:00 heroku[web.1]: Process exited with status 1
2013-03-14T08:12:40+00:00 heroku[web.1]: State changed from starting to crashed
Using
subscribe do
instead of
monitor :publish do
resolved the issue for me.
Aha! This gives me a clue. It sounds like no server instances exist before your controller is loaded. Are you perhaps referring to them in an initializer or something before the router is loaded?
Please have a look at my fork of the demo: https://github.com/mibitzi/faye-rails-demo
I changed it to use monitor :publish do
in the realtime controller.
Curiously this one also throws the same error in my development environment now.
Commenting out config.threadsafe!
in development.rb
will make it run, but it's not stable.
Moving config.threadsafe!
from development.rb
and production.rb
into application.rb
will make everything run smoothly in my development environment but will crash on heroku. This is the setup I actually have for my other application.
Maybe you can get some clues from this.
Everything seems to be working fine now with faye-rails-2.0.0 and Rails 4.
If anyone hits this again in 2.x, feel free to re-open.
When Rails eager-loads my Faye controller,
FayeRails.server(endpoint)
is returning nil in the production environment, which prevents the server from starting.The relevant part of my AnnounceController:
The line below in channel.rb is where the traceback is thrown from.
I'm unsure whether or not this is related to Rails 4.
Is this working in other apps in the production environment?