faye-rails icon indicating copy to clipboard operation
faye-rails copied to clipboard

rake aborted! eventmachine not initialized: evma_install_oneshot_timer

Open deemytch opened this issue 9 years ago • 7 comments

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

deemytch avatar Mar 13 '15 23:03 deemytch

I'm having a similar problem with Rspec, I'm stumped too. Is @jamesotron out there?

nomasprime avatar Apr 27 '15 14:04 nomasprime

https://github.com/stevegraham/em-rspec makes this error go away.

nomasprime avatar Apr 27 '15 14:04 nomasprime

I think that recent versions of rspec-rails aren't running rails initializers on startup - I'd need to confirm that with @jonrowe however.

jimsynz avatar Apr 27 '15 20:04 jimsynz

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.

JonRowe avatar Apr 27 '15 22:04 JonRowe

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.

nomasprime avatar Apr 28 '15 08:04 nomasprime

See my answer on StackOverflow for another approach.

leei avatar Jun 24 '15 20:06 leei

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 ?

clairezed avatar Jun 03 '16 15:06 clairezed