我一直在嘗試不同的配置,無法弄清楚爲什麼Thin會超時。至少這是我認爲正在發生的事情。服務器閒置一段時間後(即過夜),Thin不可用。精簡超時Nginx無法連接
環境:
- 的Ubuntu 14.04上運行AWS t2.nano
- 管理平臺:管理平臺2.6.10.stable.15251
- 紅寶石:1.9.3p484(2013年11月22日修訂43786) [x86_64的Linux的]
- 滑軌:3.2.22.2
- 薄:1.3.1代號三重咖啡
- 數據庫:MySQL的
沒有精簡錯誤日誌。錯誤日誌中的Nginx是:
2016年3月24日7時01分47秒[錯誤] 18432#0:* 1376 connect()以UNIX:/ebs_001/redmine/run/thin/redmine.0 .sock連接到上游時失敗(111:連接被拒絕),客戶端:184.166.153.12,服務器:pm.source3.com,請求:「GET/HTTP/1.1」,上游:「http://unix:/ebs_001/redmine/run/thin/redmine.0.sock:/」,主機:「pm.source3 .com「
我可以在不重新啓動Ngnix的情況下重新啓動Thin(稍後詳細介紹)和連接。
當我試圖阻止我瘦收到以下消息
[email protected]:/var/log/nginx$ sudo service thin stop
[stop] /etc/thin1.9.1/redmine.yml ...
Stopping server on /ebs_001/redmine/run/thin/redmine.0.sock ...
Sending QUIT signal to process 18385 ...
process not found!
Sending KILL signal to process 18385 ...
/usr/lib/ruby/vendor_ruby/thin/daemonizing.rb:140:in `kill': No such process (Errno::ESRCH)
from /usr/lib/ruby/vendor_ruby/thin/daemonizing.rb:140:in `force_kill'
from /usr/lib/ruby/vendor_ruby/thin/daemonizing.rb:134:in `rescue in send_signal'
from /usr/lib/ruby/vendor_ruby/thin/daemonizing.rb:118:in `send_signal'
from /usr/lib/ruby/vendor_ruby/thin/daemonizing.rb:107:in `kill'
from /usr/lib/ruby/vendor_ruby/thin/controllers/controller.rb:93:in `block in stop'
from /usr/lib/ruby/vendor_ruby/thin/controllers/controller.rb:134:in `tail_log'
from /usr/lib/ruby/vendor_ruby/thin/controllers/controller.rb:92:in `stop'
from /usr/lib/ruby/vendor_ruby/thin/runner.rb:185:in `run_command'
from /usr/lib/ruby/vendor_ruby/thin/runner.rb:151:in `run!'
from /usr/bin/thin:6:in `<main>'
後,我停止薄,然後我就可以開始瘦(須藤服務薄開始),並連接到我的管理平臺項目,無需重新啓動nxinx。 我在redmine或Thin中看不到任何錯誤日誌。
我/etc/thin/redmine.yml文件:
---
user: user1
group: group1
pid: /ebs_001/redmine/run/thin/redmine.pid
timeout: 30
wait: 30
log: /ebs_001/redmine/logs/thin/redmine.log
max_conns: 1024
require: []
environment: production
max_persistent_conns: 512
servers: 1
daemonize: true
socket: /ebs_001/redmine/run/thin/redmine.sock
chdir: /ebs_001/redmine/redmine-2.6
tag: redmine
我/etc/nginx/sites-available/redmine.conf的部分:
# Upstream Ruby process cluster for load balancing
upstream thin_cluster {
server unix:/ebs_001/redmine/run/thin/redmine.0.sock;
# server unix:/ebs_001/redmine/run/thin/redmine.1.sock max_fails=1 fail_timeout=15s;
# server unix:/ebs_001/redmine/run/thin/redmine.2.sock;
# server unix:/ebs_001/redmine/run/thin/redmine.3.sock;
}
### REDMINE - serve all pages via ssl (https)
server {
listen 80;
server_name pm.source3.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name pm.source3.com;
ssl on;
ssl_certificate /etc/nginx/ssl/redmine.crt;
ssl_certificate_key /etc/nginx/ssl/redmine.key;
include /etc/nginx/includes/redmine.include;
proxy_redirect off;
root /ebs_001/redmine/redmine-2.6;
# An alias to your upstream app
location @cluster {
proxy_pass http://thin_cluster;
# Define what a "failure" is, so it can try the next server
proxy_next_upstream error timeout http_502 http_503;
# If the upstream server doesn't respond within n seconds, timeout
proxy_read_timeout 60s;
}
location/{
try_files $uri/index.html $uri.html $uri @cluster;
}
}
...
而且../包括/ redmine.include
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
這不是一個權限問題,因爲我可以重新啓動Thin並連接到Redmine。
我只有大約15M的空閒內存。也許這是問題。但是如果是這樣的話,那麼Redmine會在我整天使用它時崩潰。
任何有關計算超時的幫助非常感謝。最後,我嘗試使用端口,而不是套接字,仍然有相同的超時問題