我已经在 AWS ubuntu trusty 14.04 配置中运行了 jruby on rails。我的服务器在几个小时内运行良好。但突然出现套接字连接失败错误。
-nginx 错误日志
2016/03/12 10:12:10 [error] 28444#0: *256477 connect() to unix:/home/deploy/shared/tmp/sockets/puma.sock failed (11: Resource temporarily unavailable) while connecting to upstream, ...
2016/03/12 10:12:11 [error] 28444#0: *256500 connect() to unix:/home/deploy/shared/tmp/sockets/puma.sock failed (111: Connection refused) while connecting to upstream, ...
2016/03/12 10:12:17 [crit] 28444#0: *256512 connect() to unix:/home/deploy/shared/tmp/sockets/puma.sock failed (2: No such file or directory) while connecting to upstream, ...
首先,出现 11:资源暂时不可用错误,然后出现 111:连接被拒绝错误,最后,不断出现 2:没有此文件或目录错误。
我搜索了这个问题并得到了这个答案。-> 需要增加 nginx 到上游 unix 套接字的吞吐量--linux 内核调整?
因此,我编辑了 /etc/sysctl.conf
net.core.somaxconn = 1024
net.core.netdev_max_backlog = 1000
但问题没有解决...仍然出现错误..
当我收到连接失败错误时,我重新启动了 puma 服务器。然后服务器就可以正常工作了。
有什么问题?我不能整天重启。请帮帮我。
nginx.conf
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 1536;
}
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
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/*;
}