I have a Sinatra :: Base object that I would like to include in all my web applications. In this base class, I have a configure method that is called at startup.
I would like this configuration code to βregisterβ this service with a centralized database. The information you need to send during registration is information on how to contact this web service ... things like the host and port.
Then I plan to have a monitoring service that will rotate over all registered services, and sometimes ping them to make sure that they are still running.
In the configure method, I am having problems getting port information. The variable 'self.settings.port' does not seem to work in this method.
a) any ideas on how to get the port? I have a host.
b) is there a sinatra plugin that already does something similar, so I don't need to write it myself ?:-)
// in my Sinatra :: Base. let's call it register_me.rb
RegisterMe <Sinatra :: Base
configure do
// store host and port information in the database
end
get '/ check_status'
// return status
end
// in my web service code
require register_me // at this point, sinatra initializes the RegisterMe object and calls configure
post ('/ blah')
// example method for this particular web service
end
Poul source
share