【发布时间】: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