faye-rails
faye-rails copied to clipboard
rake aborted! eventmachine not initialized: evma_install_oneshot_timer
Rails 4.2.0 ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-linux] thin 1.6.3
I got this error when creating/saving observed model in rake db:seed
or in console. I have this in config/initializers/faye.rb
I don't know where else do I need to check.
def running_as_server?
Rails.const_defined?('Server') || defined?(::Rack::Handler::Thin)
end
Rails.application.config.after_initialize do
unless running_as_server?
puts "--Faye.ensure_reactor_running!"
Faye.ensure_reactor_running!
end
end
and in config/application.rb
config.middleware.delete Rack::Lock
config.middleware.use FayeRails::Middleware, mount: '/quick', :timeout => 25 do
map '/registerapp/**' => ManageTabletsController
# ... more mappings
map :default => :block
end
and in ManageTabletsController
class ManageTabletsController < FayeRails::Controller
observe Device, :after_save do |r|
#some code
end
end
I'm having a similar problem with Rspec, I'm stumped too. Is @jamesotron out there?
https://github.com/stevegraham/em-rspec makes this error go away.
I think that recent versions of rspec-rails aren't running rails initializers on startup - I'd need to confirm that with @jonrowe however.
I think that recent versions of rspec-rails aren't running rails initializers on startup - I'd need to confirm that with @jonrowe however.
Only if Rails has, rspec-rails
merely adapts the Rails test helpers for use with RSpec.
Thanks @jamesotron and @JonRowe for responding so quickly, rules out initializers. This article also helped, I'm new to event callback model but just about wrapped my head around it now.
See my answer on StackOverflow for another approach.
Hello @jamesotron, thanks for your work on FayeRails ! I'm running a similar problem in a rake task, launched via a cron. (RuntimeError) "eventmachine not initialized: evma_install_oneshot_timer"
.
The error isn't raised systematically.When it is, it happens when the tasks hits a line where a custom Controller (inheriting FayeRails::Controller
) tries to publish a message.
My conf :
- ruby 2.1.2
- rails '4.1.6' *faye-rails 2.0.0
I have the same initializer as @deemytch, and I'm a bit lost regarding what I could do. The app is on production (the problem never popped while on dev) and I'm not into monkeypatching (as suggests @habitullence article). Would you have any clue on how to get rid of this error ?