Question

I'm attempting to create a Sinatra server that will return statistics about an EventMachine server. That is, I'm running:

EventMachine.run do
    server = EventMachine.start_server 'localhost', 3333, MyApp

    dispatch = Rack::Builder.app do
        map '/' do
            run MySinatraApp
        end
    end

    Rack::Server.start({
        app: dispatch,
        server: 'thin',
        Host: '0.0.0.0',
        Port: '1111'
    })
end

My goal is to figure out information on that running server started by start_server, such as connection_count. Is there any way to do this?

Was it helpful?

Solution

As far as I know there is no in-built way to do this (hopefully someone disproves me),

you can keep a counter in MyApp and +1 on connect and -1 on unbind for same effect.

OTHER TIPS

Why? Why not just have the EM server provide a /info endpoint or something that returns a dump of the information you need? Why do you need the second server? If you really want a second server then it could just be a simple sinatra app that makes a HTTP request to /info and returns the results.

For connection_count it looks like there is a EM.connection_count you can call. You can see it here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top