Is Sinatra multi threaded?

tl;dr Sinatra works well with Threads, but you will probably have to use a different web server. Sinatra itself does not impose any concurrency model, it does not even handle concurrency. This is done by the Rack handler (web server), like Thin, WEBrick or Passenger. Sinatra itself is thread-safe, meaning that if your Rack handler … Read more

How to make Sinatra work over HTTPS/SSL?

this seems to do it for me: require ‘sinatra/base’ require ‘webrick’ require ‘webrick/https’ require ‘openssl’ CERT_PATH = ‘/opt/myCA/server/’ webrick_options = { :Port => 8443, :Logger => WEBrick::Log::new($stderr, WEBrick::Log::DEBUG), :DocumentRoot => “/ruby/htdocs”, :SSLEnable => true, :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE, :SSLCertificate => OpenSSL::X509::Certificate.new( File.open(File.join(CERT_PATH, “my-server.crt”)).read), :SSLPrivateKey => OpenSSL::PKey::RSA.new( File.open(File.join(CERT_PATH, “my-server.key”)).read), :SSLCertName => [ [ “CN”,WEBrick::Utils::getservername ] ] } … Read more

Logging in Sinatra?

Sinatra 1.3 will ship with such a logger object, exactly usable as above. You can use edge Sinatra as described in “The Bleeding Edge“. Won’t be that long until we’ll release 1.3, I guess. To use it with Sinatra 1.2, do something like this: require ‘sinatra’ use Rack::Logger helpers do def logger request.logger end end

Serving static files with Sinatra

You can use the send_file helper to serve files. require ‘sinatra’ get “https://stackoverflow.com/” do send_file File.join(settings.public_folder, ‘index.html’) end This will serve index.html from whatever directory has been configured as having your application’s static files.

EventSource / Server-Sent Events through Nginx

Your Nginx config is correct, you just miss few lines. Here is a “magic trio” making EventSource working through Nginx: proxy_set_header Connection ”; proxy_http_version 1.1; chunked_transfer_encoding off; Place them into location section and it should work. You may also need to add proxy_buffering off; proxy_cache off; That’s not an official way of doing it. I … Read more