Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set Rails dev server to webbrick instead of Puma

I'm using Puma on Heroku for my server. When i have the Puma gem installed my dev environment boots up with Puma as the server. I don't seem to be able to shut that off without pulling the pum gem from my gemfile.

I like the idea of using the save server in development as production but the puma server make it difficult to track my debug statements. Also i don't seem to have a way to change max threads, comes up as 16 in dev even though my puma.rb file sets it to 1.

like image 370
bobbdelsol Avatar asked Apr 17 '14 05:04

bobbdelsol


People also ask

Does Rails use Puma?

Puma is the default server for Rails, included in the generated Gemfile.

Is Puma a web server or application server?

Nginx is a web server and puma is an application server. Both have their advantages, and you need both.

What is Puma in Ruby on Rails?

Puma is a webserver that competes with Unicorn and allows you to handle concurrent requests. Puma uses threads, in addition to worker processes, to make more use of available CPU. You can only utilize threads in Puma if your entire code-base is thread safe.

Can I run a Rails application on Puma?

You can only utilize threads in Puma if your entire code-base is thread safe. Otherwise, you can still use Puma, but must only scale-out through worker processes. This guide will walk you through deploying a new Rails application to Heroku using the Puma web server. For basic Rails setup, see Getting Started with Rails.

How do I set Puma as the server for a web process?

Set Puma as the server for your web process in the Procfile of your application. You can set most values inline: web: bundle exec puma -t 5:5 -p $ {PORT:-3000} -e $ {RACK_ENV:-development} Make sure the Procfile is appropriately capitalized and checked into git. Create a configuration file for Puma at config/puma.rb or at a path of your choosing.

How do I access the production environment of my Rails application?

Now the production environment of your Rails application is accessible via your server’s public IP address or FQDN. To access the Tasks controller that we created earlier, visit your application server in a web browser:

How do I test if my Rails application is working?

To test out if your application works, you can run the production environment, and bind it to the public IP address of your server (substitute your server’s public IP address): Now visit this URL in a web browser: If it’s working properly, you should see this page: Go back to your Rails server, and press Ctrl-c to stop the application.


1 Answers

Just use puma in production mode. In your gemfile change gem 'puma' with

#Gemfile
group :production do
  gem 'puma'
end

and then run bundle install --without production to install the gem .

like image 172
Monideep Avatar answered Oct 12 '22 00:10

Monideep