3

Sinatra アプリで簡単なテストを行いました。長いハンドラーを呼び出すと、ダミーのリクエストがブロックされます。

 get '/test/long' do
    sleep 10
    "finished"
 end 

 get '/test/dummy' do
    "dummy"

 end

次のコマンドを使用してサーバーを起動しました。

bundle exec rackup -s thin

Is Sinatra multi threaded?によると 、Thin はマルチスレッド Web サーバーである必要があります。ここで私の問題は何ですか?

my Gemfile:
source :rubyforge
gem 'sinatra',           '1.2.6', :require => 'sinatra/base'

gem 'geokit',        '1.6.0', :require => 'geokit'
gem 'json',              '1.5.3'
gem 'dm-core',           '1.2.0'
gem 'dm-timestamps',     '1.2.0'
gem 'dm-migrations',     '1.2.0'
gem 'dm-mysql-adapter',  '1.2.0'
gem 'rack-cache',        '1.0.1', :require => 'rack/cache'
gem 'rake',              '10.0.0',  :require => nil
gem 'hashie',            '1.0.0'
gem 'thin'
gem 'shotgun'
gem 'rack-mobile-detect', '0.3.0', :require => 'rack/mobile-detect'
gem 'aws-ses',                     :require => 'aws/ses'
4

2 に答える 2

9

Thin can be multi-threaded, but only if you configure it to be so, by default it is single-threaded (evented). From the answer to the question you linked to:

since Sinatra 1.3.0, Thin will be started in threaded mode, if it is started by Sinatra (i.e. with ruby app.rb, but not with the thin command, nor with rackup).

There doesn’t appear to be a way to get rackup to pass the threaded option through to Thin, so you will need to use either thin start --threaded or ruby my_app.rb to get threading on Thin.

于 2013-07-10T13:36:34.140 に答える