views:

31

answers:

2

Hi all,

I have a rails app and I run the main rails app on a mongrel server. However, I also have an comet server (using EventMachine) running using the rails environment (so it can access the database). However, Mongrel seems to mess up EventMachine. My question is, how can I detect whether or not I am running the rails environment from the rails server or from the EventMachine server so I can require the mongrel gem only in that case.

Thanks.

A: 
request.server_software()

http://api.rubyonrails.org/classes/ActionController/Request.html#M000515

Nikita Rybak
This won't work because the EventMachine server never touches ActionController. It loads the rails environment exclusively for the purpose of using activerecord.
Maz
@Maz So, what's the problem then? If you're under mongrel, this code will return 'mongrel', otherwise there probably will be no '@env' variable (or no 'SERVER_SOFTWARE' value in it).
Nikita Rybak
A: 

I figured out what to do. I already have some global variables declared for the EventMachine server, so I check to see whether or not they're defined. If they are not, then I know it's not running the EventMachine server.

Maz