Puma --Nignx is an escape route when rails s -e production -d doesn't work in the environment

Premise

Deployed to EC2 with Rails6 + Puma + Nginx And at the terminal SSH connected to EC2

rails s -e production 

Then the service is displayed without any problem

rails s -e production -d

Then the error screen is displayed?

Yeah ~ I'm still connected to SSH to keep the service running

It's for you who have troubles!

Solution

In config / puma.rb in the Rails root folder

config/puma.rb


daemonize

I will add it! with this

rails s -e production -d

I can't start it

rails s -e production 

This will make it a daemon, so it's a solution!

People who think that this is inconvenient even locally as a daemon

config/puma.rb


if Rails.env == 'production'
  daemonize
end

Let's write! It's a workaround that anyone can think of! I'm sorry to write it as I knew it!

Cause

I haven't completely investigated it, but as a result of becoming a net surfer and diving in the sea of google, it seems that puma.rb is not loaded when it is daemonized with "rails s -d" in puma. When I started with rails s -e production -d, I could not connect to the Nginx error log with the socket set in puma.rb! Because it is described, I think that it is probably correct.

This guy is bad! Please point out any points!

Recommended Posts

Puma --Nignx is an escape route when rails s -e production -d doesn't work in the environment
[Beginner] When rails s doesn't work
[Programming beginner] What to do when rails s becomes an error in the local development environment
[Rails] Reset the database in the production environment
[Rails] About the error that the image is not displayed in the production environment
Rails5.1 + puma SSL connection in local production environment
SSL in the local environment of Docker / Rails / puma
[Error] The app is not displayed in the production environment
It doesn't work if the Map key is an array
Error in production environment (The asset "~" is not present in the asset pipeline.)
Exit code 1 occurs when Rails is stopped in Docker environment
Breakpoint doesn't work when running Rails Minitest in Ruby Test Explorer
When log data accumulates in Rails and the environment stops working
[Rails] How to reset the database in production environment (Capistrano version)
How to write the view when Vue is introduced in Rails?
Pay.JP Solution when it can be done locally but it does not work well in the production environment
Is there an engineer who hasn't validated the Json column in Rails?