【问题标题】:How to generate a puma.sock file on production ruby on rails如何在生产 ruby​​ on rails 上生成 puma.sock 文件
【发布时间】:2020-05-16 15:00:32
【问题描述】:

使用 puma 在 AWS EC2 上部署我的 Ruby on Rails 应用程序。当我点击 url 时,nginx 给出了 puma.sock 不存在的错误。

*connect() to unix:/home/ubuntu/peatio/shared/sockets/puma.sock failed (2: No such file or directory) while connecting to upstream, client: 44.225.84.206, server: localhos

如何生成 puma.sock?

config/puma.rb

threads_count = ENV.fetch("RAILS_MAX_THREADS") { 2 }
threads threads_count, threads_count
port ENV.fetch("PORT") { 3000 }
environment ENV.fetch("RAILS_ENV") { "production" }
plugin :tmp_restart
# Change to match your CPU core count
workers 1
# Min and Max threads per worker
threads 1, 6
app_dir = File.expand_path("../..", __FILE__)
shared_dir = "#{app_dir}/shared"
# Default to production
rails_env = ENV['RAILS_ENV'] || "production"
environment rails_env
# Set up socket location
bind "unix://#{shared_dir}/shared/sockets/puma.sock"
# Logging
stdout_redirect "#{shared_dir}/log/puma.stdout.log", "#{shared_dir}/log/puma.stderr.log", true
# Set master PID and state locations
pidfile "#{shared_dir}/pids/puma.pid"
state_path "#{shared_dir}/pids/puma.state"
activate_control_app
on_worker_boot do
require "active_record"
  ActiveRecord::Base.connection.disconnect! rescue ActiveRecord::ConnectionNotEstablished
  ActiveRecord::Base.establish_connection(YAML.load_file("#{app_dir}/config/database.yml")[rails_env])
end

如何生成 puma.sock 文件?

【问题讨论】:

  • 与您上次发布此问题时的问题相同:您确定unix:/home/ubuntu/peatio/shared/sockets/puma.sock"unix://#{shared_dir}/shared/sockets/puma.sock" 是同一条路径吗?
  • @anothermh #{shared_dir} 是项目的路径
  • 所以是一样的
  • 那么 Rails 没有启动。
  • 怎么做?

标签: ruby-on-rails ruby nginx puma


【解决方案1】:

试试这个: cap production puma:start

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-08
    • 2018-12-15
    • 2012-12-27
    相关资源
    最近更新 更多