Unicorn + Nginx Rails 生产错误

Unicorn + Nginx Rails production error

我正在按照 this tutorial 使用 Capistrano 部署 RoR 应用程序,但我的生产服务器出现错误

[error] 28314#0: *1 connect() to unix:/tmp/unicorn.myapp.sock failed (111: Connection refused) while connecting to upstream, client: xx.xxx.xx.xx, server: , request: "GET / HTTP/1.1", upstream: "http://unix:/tmp/unicorn.myapp.sock:/", host: "myapp.cloudapp.azure.com"

我的/etc/nginx/sites-available/default

upstream app {
  # Path to Unicorn SOCK file, as defined previously
  server unix:/tmp/unicorn.myapp.sock fail_timeout=0;
}

server {

  listen 3000;
  server_name localhost;

  root /home/deploy/apps/myapp/current/;

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

  location @app {
    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;
}

我将 server 更改为许多不同的东西,但我得到完全相同的错误,具有相同的主机、服务器和上游。

问题出在我的 Capistrano 部署中的 Unicorn 上,它没有按预期重启 Unicorn。

Nginx 日志表明这是后端服务器的问题。在您的后端启动并且 运行 之后。检查:

一旦这些测试通过,通过 Nginx 再次测试。