[英]How to debug Puma sock connection
UPDATE UPDATE
From @BoraMa's comment - I realized my puma.rb (which was all boilerplate) didn't have the socket location setup properly. 从@BoraMa的评论开始-我意识到我的puma.rb(全部都是样板)没有正确设置套接字位置。 However, I'm unsure how to make these match... Does it matter where my sock location is? 但是,我不确定如何进行匹配...袜子位置在哪里有关系吗? Can I put it anywhere? 我可以放在任何地方吗?
My path from my sites-available file is - 我的网站可用文件中的路径是-
"unix:///home/deploy/apps/mll/shared/tmp/sockets/mll-puma.sock:/"
however, I logged out the app_dir
seen below, and I get: 但是,我注销了如下所示的app_dir
,并且得到了:
/home/deploy/apps/mll/releases/20160415184544
So I'm unsure how I can get these to match/what I should use, since it looks like it's using my capistrano releases in the puma.rb 所以我不确定如何使它们匹配/应该使用什么,因为看起来它正在使用puma.rb中的capistrano版本
My updated puma.rb 我更新的puma.rb
# Change to match your CPU core count
workers 1
# Min and Max threads per worker
threads 1, 6
app_dir = File.expand_path("../..", __FILE__)
puts "App dir: #{app_dir}"
# App dir: /home/deploy/apps/mll/releases/20160415184544
shared_dir = "#{app_dir}"
# Default to production
rails_env = ENV['RAILS_ENV'] || "production"
environment rails_env
# Set up socket location
# bind "unix://#{shared_dir}/sockets/puma.sock"
bind "unix://#{shared_dir}/tmp/sockets/mll-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
Note - I was originally following: https://www.digitalocean.com/community/tutorials/deploying-a-rails-app-on-ubuntu-14-04-with-capistrano-nginx-and-puma 注意-我最初是在关注以下内容: https : //www.digitalocean.com/community/tutorials/deploying-a-rails-app-on-ubuntu-14-04-with-capistrano-nginx-and-puma
Original Post 原始帖子
I'm trying to run Puma via Capistrano/Capistrano gem on Nginx for a rails app. 我正在尝试通过Nginx上的Capistrano / Capistrano gem运行Puma,以用于Rails应用程序。
After running cap production deploy:initial
and loading my browser, I get An unhandled lowlevel error occurred. The application logs may have details.
运行cap production deploy:initial
并加载浏览器后, An unhandled lowlevel error occurred. The application logs may have details.
An unhandled lowlevel error occurred. The application logs may have details.
I'm not very familiar with Puma/Sockets/Permissions. 我对Puma / Sockets / Permissions不太熟悉。
My log shows: 我的日志显示:
[crit] 27411#0: *2 connect() to unix:///home/deploy/apps/mll/shared/tmp/sockets/mll-puma.sock failed (13: Permission denied) while connecting to upstream,
client: my_ip_address,
server: mysite.com,
request: "GET / HTTP/1.1",
upstream: "http://unix:///home/deploy/apps/mll/shared/tmp/sockets/mll-puma.sock:/",
host: "centers.m$
/etc/nginx/sites-available/centers - / etc / nginx / sites-available / centers-
upstream mll-puma {
server unix:///home/deploy/apps/mll/shared/tmp/sockets/mll-puma.sock;
}
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /home/deploy/apps/mll/current/public;
access_log /home/deploy/apps/mll/current/log/nginx.access.log;
error_log /home/deploy/apps/mll/current/log/nginx.error.log info;
server_name centers.mrs-lodges-library.com;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @puma;
location @puma {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://mll-puma;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 10M;
keepalive_timeout 10;
}
puma.rb, pretty much boilerplate, didn't change any settings puma.rb,几乎是样板,没有更改任何设置
# 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}/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
/etc/nginx/nginx.conf /etc/nginx/nginx.conf
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
server_names_hash_bucket_size 64;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
gzip_disable "msie6";
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
Permissions: 权限:
namei -l /var/www/centers/ 名称-l / var / www / centers /
drwxr-xr-x root root /
drwxr-xr-x root root var
drwxr-xr-x root root www
drwxrwxr-x root root centers
namei -l /home/deploy/apps/mll/current/public/ 名称-l / home / deploy / apps / mll / current / public /
drwxr-xr-x root root /
drwxr-xr-x root root home
drwxr-xr-x deploy deploy deploy
drwxr-xr-x deploy deploy apps
drwxr-xr-x deploy deploy mll
lrwxrwxrwx deploy deploy current -> /home/deploy/apps/mll/releases/20160415164906
drwxr-xr-x root root /
drwxr-xr-x root root home
drwxr-xr-x deploy deploy deploy
drwxr-xr-x deploy deploy apps
drwxr-xr-x deploy deploy mll
drwxr-xr-x deploy deploy releases
drwxrwxr-x deploy deploy 20160415164906
drwxrwxr-x deploy deploy public
deploy@banana:/etc/nginx$
Sockets - 插座-
$ ls -l $ ls -l
drwxr-xr-x 2 deploy deploy 4096 Apr 14 18:22 pids
drwxr-xr-x 2 deploy deploy 4096 Apr 14 18:22 sockets
$ ls -l $ ls -l
srwxrwxrwx 1 deploy deploy 0 Apr 14 18:22 mll-puma.sock
I think that in your puma.rb
and nginx
site configuration files you should point puma / nginx to the same socket. 我认为在puma.rb
和nginx
站点配置文件中,应该将puma / nginx指向同一套接字。 Right now there are different paths. 现在有不同的路径。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.