在使用capistrano3部署我的rails应用程序之后,我的应用程序第一次运行良好,但是有时我在nginx.error.log中遇到了此错误:
unix:/var/www/appname/shared/tmp/sockets/puma.sock failed (111: Connection refused) while connecting to upstream
这是我在/ etc / nginx / site-available /
中的conf文件upstream puma_appname_production {
server unix:/var/www/appname/shared/tmp/sockets/puma.sock
fail_timeout=0;
}
server {
listen 80;
# server_name domaine.com;
root /var/www/appname/current/public;
try_files $uri/index.html $uri @puma_appname_production;
client_max_body_size 4G;
keepalive_timeout 10;
error_page 500 502 504 /500.html;
error_page 503 @503;
location @puma_appname_production {
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header X-Forwarded-Proto http;
proxy_pass http://puma_appname_production;
# limit_req zone=one;
access_log /var/www/appname/shared/log/nginx.access.log;
error_log /var/www/appname/shared/log/nginx.error.log;
}
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
location = /50x.html {
root html;
}
location = /404.html {
root html;
}
location @503 {
error_page 405 = /system/maintenance.html;
if (-f $document_root/system/maintenance.html) {
rewrite ^(.*)$ /system/maintenance.html break;
}
rewrite ^(.*)$ /503.html break;
}
if ($request_method !~ ^(GET|HEAD|PUT|PATCH|POST|DELETE|OPTIONS)$ ){
return 405;
}
if (-f $document_root/system/maintenance.html) {
return 503;
}
}
我每次都需要恢复部署以便它可以正常工作。我不知道会发生什么