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

How is the best way to start the EM on a Puma in cluster mode and on a Rails app? #986

Open
cavi21 opened this issue Nov 24, 2023 · 0 comments

Comments

@cavi21
Copy link

cavi21 commented Nov 24, 2023

I'm trying to run EventMachine on an webserver that use Puma in cluster mode (so multiple workers are started), and that's running a Rails application and I found it hard to realize where should I start the EM.run { ... }, because I needed as a long running process because is needed to process messages using another gem called Faye.

If a put it in an rails initializer it seems that the code run every time a puma worker is spawned, so if I have multiple 4 workers, there will be 4 times that a code like this runs:

      if EventMachine.reactor_running?
        puts "[reactor_running]...."
        EventMachine.stop
      end
      Thread.new { EventMachine.run }

Is this a correct way to start only one EM? or how I should approach this? any pointer is appreciate it :)! thankss

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

1 participant