railsアプリケーションのpuma.rb設定に関する質問です。
以下のデーモン化とログ出力先の設定をpuma.rbに記載したいのですが、本番環境時のみ反映したいです。開発環境時は不要。
daemonize true stdout_redirect "/var/log/puma/puma.stdout.log", "/var/log/puma/puma.stderr.log", true
puma.rb上での環境切り分けはどのように行えば良いのでしょうか??
以下のような切り分けで良いのでしょうか?
if Rails.env.production? daemonize true stdout_redirect "/var/log/puma/puma.stdout.log", "/var/log/puma/puma.stderr.log", true end
※以下はpuma.rbの全記述になります。
app_root = File.expand_path("../..",__FILE__) bind "unix://#{app_root}/tmp/sockets/puma.sock" pidfile "#{app_root}/tmp/pids/puma.pid" state_path "#{app_root}/tmp/pids/puma.state" daemonize true stdout_redirect "/var/log/puma/puma.stdout.log", "/var/log/puma/puma.stderr.log", true threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i threads threads_count, threads_count port ENV.fetch("PORT") { 3000 } environment ENV.fetch("RAILS_ENV") { "production" } workers ENV.fetch("WEB_CONCURRENCY") { 2 } preload_app! on_worker_boot do ActiveRecord::Base.establish_connection if defined?(ActiveRecord) end plugin :tmp_restart before_fork do PumaWorkerKiller.config do |config| config.ram = 3072 # mb config.frequency = 30 # seconds config.percent_usage = 0.65 config.rolling_restart_frequency = 12 * 3600 # 12 hours in seconds, or 12.hours if using Rails end PumaWorkerKiller.start ActiveRecord::Base.connection_pool.disconnect! if defined?(ActiveRecord) end
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/07/18 08:00
2019/07/18 08:10
2019/07/18 09:28
2019/07/18 23:38