【发布时间】:2016-11-20 08:24:36
【问题描述】:
我正在使用 nginx、puma 和 capistrano 部署我的 Rails 应用程序。它由名为 deploy 的用户部署,部署位置在主目录下 (/home/deploy)
我已将 Puma 配置为在 shared 文件夹下创建一个套接字,Capistrano 将其所有发布符号链接到该文件夹。相应地,nginx 也被配置为查看该套接字(请参阅下面的配置文件)
但是,当我启动 Rails / Puma 网络服务器时 -
cd /home/deploy/my_app/current
SECRET_KEY_BASE=.... DATABASE_PASSWORD=... rails s -e production
我注意到没有创建套接字文件。当我在浏览器中访问该站点然后查看 Nginx 错误日志时,它还抱怨该套接字不存在。
2016/07/17 14:26:19 [crit] 26055#26055: *12 connect() to unix:/home/deploy/my_app/shared/tmp/sockets/puma.sock failed (2: No such file or directory) while connecting to upstream, client: XX.YY.XX.YY, server: localhost, request: "GET http://testp4.pospr.waw.pl/testproxy.php HTTP/1.1", upstream: "http://unix:/home/deploy/my_app/shared/tmp/sockets/puma.sock:/500.html", host: "testp4.pospr.waw.pl"
如何让 puma 创建那个套接字?
谢谢!
彪马配置
# config/puma.rb
...
# `shared_dir` is the symlinked `shared/` directory created
# by Capistrano - `/home/deploy/my_app/shared`
# Set up socket location
bind "unix://#{shared_dir}/tmp/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}/tmp/pids/puma.pid"
state_path "#{shared_dir}/tmp/pids/puma.state"
activate_control_app
...
Nginx 站点配置
# /etc/nginx/sites-available/default
upstream app {
# Path to Puma SOCK file
server unix:/home/deploy/my_app/shared/tmp/sockets/puma.sock fail_timeout=0;
}
server {
listen 80;
server_name localhost;
root /home/deploy/my_app/public;
try_files $uri/index.html $uri @app;
location @app {
proxy_pass http://app;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
【问题讨论】:
标签: ruby-on-rails sockets nginx capistrano puma