Search code examples
ruby-on-railswebserverunicornpumagemfile

rails: What happens when two web servers are specified in a Gemfile


If two web servers (say puma and unicorn) are specified in the Gemfile, which one gets precedence?

I tried doing this myself but realized I was on windows with not much ruby support.


Solution

  • Long Answer with example:

    1. you created app with rails 5.0.0, you get puma webserver by default.
    2. you install unicorn gem. and you start the server by rails server still your server is puma. why ? because config/puma.rb file which generated with rails new application-name .
    3. To start unicorn server you have to created one file for unicorn in config folder.
    4. To start unicorn server you have to execute command like this unicorn -c config/unicorn.rb in your terminal. I think this is the answer of your question.

    Short answer:

    You have tell rails explicitly which webserver you have to run. Rails will not decide which to run (in case of multiple web server).

    I hope this clear your doubts. Cheers