Search code examples
sinatrarackpuma

How to use puma in production mode by set production environment?


I made a little Sinatra app. In my Gemfile add gem 'puma' in the production group

group :production do
    gem 'puma'
    gem 'dm-postgres-adapter'
end

And I set production mode in config.ru

set :environment, :production

But after I run backup, the default webrick web server run instead. How can I solve this?


Solution

  • Just use puma :)

    $ puma config.ru
    

    You can run your Sinatra application with Puma from the command line like this:

    $ ruby app.rb -s Puma
    

    Or you can configure your application to always use Puma:

    require 'sinatra'
    configure { set :server, :puma }
    

    You can pass it as an option to rackup:

     $ rackup -s Puma
    

    Alternatively, you can modify your config.ru to choose Puma by default, by adding the following as the first line:

     #\ -s puma
    

    More documentation on puma.