-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
properly running sinatra with miltithreading support #937
Comments
Good news: In 2014 Sinatra is run just the way it was in 2013. Your require './app'
run LongNamespace::App It is also not recommended to inherit from You should also I'd generally recommend using a config.ru for any complex application. See the documentation for main points on how things differ. require 'sinatra/base'
module LongNamespace
class App < Sinatra::Base
# ...
run! if app_file == $0
end
end Concerning multithreading, I'd recommend taking a look at the "Is Sinatra multi threaded?" question on StackOverflow. Please let us know on how we can improve our documentation. Threads aren't really covered at the moment (since Sinatra itself is not really concerned with your concurrency model) in our README, we should probably change that, but then again, your issues seem not to be related to threading. |
Alright, so the basic idea is never use Good, I managed to get thin working in multi-thread when run via That stackoverflow question brings zero value to me as it doesn't explain on how to run sinatra via rack while enabling multi-threading. I understand there's a mix of unrelated technologies and software here, but I need to run that together and there should be a document on how to do it.
Thanks! |
You'll have to pass in which server to use when running backup, like On Thu, Oct 23, 2014 at 9:44 PM, celesteking notifications@github.com
|
Yes, with |
On Sat, Oct 25, 2014 at 1:56 PM, celesteking notifications@github.com
|
That indeed helped. |
thin shouldn't need to be threaded. It's driven by Event machine so should be able to handle a multiple requests from one thread / process provided your code isn't performing any long blocking operations |
This is not entirely true. Unless you use some mechanism to give back On Mon, Feb 9, 2015 at 2:43 PM, Jason Earl notifications@github.com wrote:
|
According to what was mentioned, there are 3 methods of starting sinatra:
Should this be condensed somehow? |
You can also start Sinatra from a custom Ruby script, by invoking |
Issue: sinatra#941 Discussion: sinatra#937 Although threading depends on the underlying Rack handler, the absence of any mention of multi-threaded mode/concurrency seems to confuse users and it was decided to add some pointers to clarify this.
I've got a problem. Your docs don't specify on how to run Sinatra properly in 2014.
I'd like it to support multithreading.
Currently, I have:
Now, where do I place
LongNamespace::App.run! if LongNamespace::App.app_file == $0
? I tried placing it at the bottom of file, which led to running the server twice on Ctrl+C.I've tried a rackup with config.ru:
This works perfectly (multithread), but outputs on Ctrl+C:
I tried
LongNamespace::App.run if LongNamespace::App.app_file == $0
, this doesn't pick up any routes, server is running like an empty one.And I'm yet to actually start coding.
The text was updated successfully, but these errors were encountered: