I am running a Sinatra application locally.
Ever since I installed Thin, my Sinatra app always uses it as the web server. However, I have been having performance issues with Thin serving the large amount of static files required by my application, and I would like to switch to either Mongrel or WEBrick.
I cannot seem to figure out how to switch my application over to Mongrel or WEBrick. Even when I put require 'mongrel'
or require 'webrick'
at the top of my app.rb, upon a ruby app.rb
, Sinatra still starts with Thin.
So, my question is: how do you specify the web server for Sinatra to use in development mode? Also, how could I do so in production mode?
Sinatra is a lightweight domain-specific programming language and web application library that is used for writing web applications. It provides a faster and simpler alternative to Ruby frameworks such as Ruby on Rails.
You can set the server Sinatra uses with the :server
configuration setting:
set :server, 'webrick' # or thin, mongrel
In production, it is much better to use a more sophisticated server like Phusion Passenger or Unicorn, since they have better performance than Thin, Mongrel, or WEBrick. If you choose Passenger or Unicorn, you would not configure the server within your Sinatra application file itself, but instead typically configure it separately using a Rackup config.ru file.
"Ruby on Rails Server options" is aimed at Rails applications, but is still very relevant for Sinatra apps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With