我正在构建一个需要可线程化的Sinatra应用程序,因为我使用sucker-punch进行工作,我想使用Puma服务器执行此操作但我从未使用过它之前。
出于某种原因,当我启动我的应用程序时,它会运行Thin。
我卸载了Thin并且它使用了Puma,这很好,但是如果再次出现这种情况,我怎么能阻止它在未来开始使用Thin?
我使用rackup
开始我的应用程序,并且我的主app.rb文件中有:
class App < ::Sinatra::Base
configure do
set :show_exceptions, true
set :root, Info[:root]
set :threaded, true
set :server, :puma
Tilt.register Tilt::ERBTemplate, 'html.erb'
enable :logging
use Rack::CommonLogger, Log.file
if ENV['APP_ENVIRONMENT'] == 'PROD'
set :environment, :production
set :bind, '0.0.0.0', HOST
set :show_exceptions, false
end
end
end
答案 0 :(得分:3)
您需要在config.ru
rackup文件中设置服务器。在此文件中,您可以设置
Rack::Handler.get('puma').run App.new
文档位于“Module: Rack::Handler”。
然而,更好的方法是明确地运行Puma:
bundle exec puma config.ru
根据@matt的建议:
rackup -s puma
答案 1 :(得分:2)
只需使用bundle exec
运行它。这样可以确保可用的gem只是Gemfile中指定的gems。
所以,即使你已经安装了瘦机,但你的Gemfile上有puma,它会选择puma。