2

Problem statement

I'm deploying my Rails 7 app on render.com and shortly after launching, the logs show that Puma is shutting down the workers. The config file is mostly unmodified from what ships with Rails.

Question

Is this expected behavior, to shut down the workers shortly after deploying? Is there somewhere I can go inspect what's happening under the hood?

Log output

Sep 10 05:21:59 PM  ==> Starting service with 'bundle exec puma -C config/puma.rb'
Sep 10 05:22:01 PM  [70] Puma starting in cluster mode...
Sep 10 05:22:01 PM  [70] * Puma version: 5.6.4 (ruby 3.1.1-p18) ("Birdie's Version")
Sep 10 05:22:01 PM  [70] *  Min threads: 5
Sep 10 05:22:01 PM  [70] *  Max threads: 5
Sep 10 05:22:01 PM  [70] *  Environment: production
Sep 10 05:22:01 PM  [70] *   Master PID: 70
Sep 10 05:22:01 PM  [70] *      Workers: 4
Sep 10 05:22:01 PM  [70] *     Restarts: (✔) hot (✖) phased
Sep 10 05:22:01 PM  [70] * Preloading application
Sep 10 05:22:07 PM  [70] * Listening on http://0.0.0.0:10000
Sep 10 05:22:07 PM  [70] Use Ctrl-C to stop
Sep 10 05:22:07 PM  [70] - Worker 1 (PID: 77) booted in 0.01s, phase: 0
Sep 10 05:22:07 PM  [70] - Worker 2 (PID: 83) booted in 0.01s, phase: 0
Sep 10 05:22:07 PM  [70] - Worker 0 (PID: 75) booted in 0.03s, phase: 0
Sep 10 05:22:07 PM  [70] - Worker 3 (PID: 93) booted in 0.0s, phase: 0
Sep 10 05:23:15 PM  [69] === puma shutdown: 2022-09-10 22:23:15 +0000 ===
Sep 10 05:23:15 PM  [69] - Goodbye!
Sep 10 05:23:15 PM  [69] - Gracefully shutting down workers...

Puma config file

# frozen_string_literal: true

max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
threads min_threads_count, max_threads_count

worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"

port ENV.fetch("PORT") { 3000 }

environment ENV.fetch("RAILS_ENV") { "development" }

pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }

if ENV.fetch("RAILS_ENV") == "production"
  workers ENV.fetch("WEB_CONCURRENCY") { 4 }
end

if ENV.fetch("RAILS_ENV") == "production"
  preload_app!
end

# --- START modified config from what ships with Rails 7 ---
on_worker_boot do
  ActiveSupport.on_load(:active_record) do
    ActiveRecord::Base.establish_connection
  end
end

lowlevel_error_handler do |e|
  Bugsnag.notify(e)
end
# --- END modified config from what ships with Rails 7 ---

plugin :tmp_restart
chemturion
  • 283
  • 2
  • 16

0 Answers0