I have a Sinatra Application enclosed in Sinatra::Base and I\'d like to run some code once the server has started, how should I go about doing this?
Her
This is how I do it; basically running either sinatra or the other code in a separate thread:
require 'sinatra/base'
Thread.new {
sleep(1) until MyApp.settings.running?
p "this code executes after Sinatra server is started"
}
class MyApp < Sinatra::Application
# ... app code here ...
# start the server if ruby file executed directly
run! if app_file == $0
end