title: Execute code once Sinatra server is running
body: <p>I have a Sinatra Application enclosed in <code>Sinatra::Base</code> and I'd like to run some code once the server has started, how should I go about doing this?</p>
  
  <p>Here's an example:</p>
  
  <pre><code>require 'sinatra'
  require 'launchy'
  
  class MyServer &lt; Sinatra::Base
    get '/' do
      "My server"
    end
  
    # This is the bit I'm not sure how to do
    after_server_running do
      # Launches a browser with this webapp in it upon server start
      Launchy.open("http://#{settings.host}:#{settings.port}/")
    end
  end
  </code></pre>
  
  <p>Any ideas?</p>