This is a little out of the ordinary for a normal Ruby/Rails application. I am building an application that mostly runs on top of Event Machine. There are a few HTML files that are served up from WEBrick, but the majority of the application runs client-side with javascript, with a Web Socket connection to my Event Machine application. I need to be able to accept file uploads and store them locally. How can this be done?
Update: If you’re interested, here is a link to the source code.
First here is how to build a simple file upload with sinatra: File upload with Sinatra
So now to run your web server with thin you can do this in your code:
thin uses eventmachine internally, I suppose webrick uses threads but honestly I never really looked into it.
You should use apache or nginx in front of your ruby process at least for the file upload (I think websockets won’t work through it).
I can include a simple nginx config if you need (just need to find it on my disk xD).
Edit: Another solution is to use goliath as web server, you have an example here: https://github.com/postrank-labs/goliath/blob/master/examples/async_upload.rb
If you don’t need to display upload progress you should stay with sinatra+nginx/apache.