捆绑器:无法加载命令:puma - Errno::EACCES:权限被拒绝 - 连接(2)

bundler: failed to load command: puma - Errno::EACCES: Permission denied - connect(2)

当我运行

vagrant@localhost:/app$ /home/vagrant/.rbenv/shims/bundle exec puma -C /app/config/puma.development.rb -b unix:/var/tmp/app/sockets/puma.development.sock

我得到一个错误:

[7159] Puma starting in cluster mode...
[7159] * Version 3.10.0 (ruby 2.5.1-p57), codename: Russell's Teapot
[7159] * Min threads: 5, max threads: 5
[7159] * Environment: development
[7159] * Process workers: 2
[7159] * Preloading application
[7159] * Listening on unix:/var/tmp/app/sockets/puma.development.sock
bundler: failed to load command: puma (/home/vagrant/.rbenv/versions/2.5.1/bin/puma)
Errno::EACCES: Permission denied - connect(2) for /var/tmp/app/sockets/puma.development.sock

问题似乎是没有创建 .sock 文件。或者在 Puma 关闭时创建然后删除:

vagrant@localhost:/var/tmp/app/sockets$ ls -al
total 8
drwxr-xr-x 2 root root 4096 Jun  1 13:27 .
drwxr-xr-x 4 root root 4096 May 28 16:09 .. 

这是我的 nginx site.conf:

vagrant@localhost:/var/tmp/app/sockets$ cat /etc/nginx/sites-enabled/localhost.conf
# Ansible managed    

upstream app {
  server unix:/var/tmp/app/sockets/puma.development.sock fail_timeout=0;
}    

server {
  listen 80;
  listen 443 ssl;    

  sendfile off;    

  server_name localhost;    

  root /app/public;    

  try_files $uri/index.html $uri @app;    

  location @app {
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_redirect off;
    proxy_pass http://app;
  }    

  error_page 500 502 503 504 /500.html;
  client_max_body_size 4G;
  keepalive_timeout 10;    

}

如您所料,nginx 日志显示上游连接错误:

2018/06/01 14:15:54 [crit] 1941#0: *5 connect() to unix:/var/tmp/app/sockets/puma.development.sock failed (2: No such file or directory) while connecting to upstream, client: 10.0.2.2, server: localhost, request: "GET / HTTP/1.1", upstream: "http://unix:/var/tmp/app/sockets/puma.development.sock:/", host: "localhost:8080"

这是我的 puma.development.rb 文件:

# Ansible managed    

# Feel free to experiment with this, 0/16 is a good starting point.
threads_count = Integer(ENV['MAX_THREADS'] || 5)
threads threads_count, threads_count    

# Go with at least 1 per CPU core, a higher amount will usually help for fast
# responses such as reading from a cache.
workers Integer(ENV['WEB_CONCURRENCY'] || 2)    

# Listen on a tcp port or unix socket.
bind "unix:/var/tmp/app/sockets/puma.development.sock"    

# Set Port/Rack/Env
rackup DefaultRackup
port 3000
environment "development    

# The path where the pid file will be written to.
pidfile "/var/tmp/app/pids/puma.development.pid"    

# Use a shorter timeout instead of the 60s default. If you are handling large
# uploads you may want to increase this.
worker_timeout 3    

# The file that gets logged to.
stdout_redirect "/app/log/puma.development.log", "/app/log/puma.development.err.log"    

# Preload the application before starting the workers.
preload_app!    

# The path to the puma binary without any arguments, it will inherit everything
# from the original process.
restart_command 'bin/puma'    

on_worker_boot do
  # Don't bother having the master process hang onto older connections.
  defined?(ActiveRecord::Base) and
    ActiveRecord::Base.connection.disconnect    

  defined?(ActiveRecord::Base) and
    ActiveRecord::Base.establish_connectio    


end

感觉我在这里遗漏了一些明显的东西,但对于我的生活我无法弄清楚它是什么。

提前致谢!

错误的用户?套接字文件的目录属于 root 但您以 vagrant.

启动应用程序