Unicorn.sock failed 111 connection refused
26.11.2016, 12:08. Показов 3631. Ответов 1
Приветствую!
ОЧЕНЬ прошу помощи. Я в ruby не силён и мне сложно понять, где ошибка.
Мы в процессе переноса серверов на другой VDS + недавно слетели все А-записи на домене 
Есть сервер, имеющий внешний IP адрес и внутренний 10.1.1.12. на нём находятся домены api.server.info и server.info
error.log nginx с внешнего сервера
| Code | 1
2
3
4
5
6
7
8
9
10
| 2016/11/26 11:27:25 [error] 24345#0: *2913 connect() to unix:/home/deployer/api/shared/tmp/sockets/unicorn.sock failed (111: Connection refused) while connecting to upstream, client: 66.249.64.76, server: api.server.info, request: "GET /companies/7815020097/claims/5822/solutions HTTP/1.1", upstream: "http://unix:/home/deployer/api/shared/tmp/sockets/unicorn.sock:/companies/7815020097/claims/5822/solutions", host: "api.server.info"
2016/11/26 11:27:25 [error] 24345#0: *2914 connect() to unix:/home/deployer/api/shared/tmp/sockets/unicorn.sock failed (111: Connection refused) while connecting to upstream, client: 66.249.64.81, server: api.server.info, request: "GET /robots.txt HTTP/1.1", upstream: "http://unix:/home/deployer/api/shared/tmp/sockets/unicorn.sock:/robots.txt", host: "api.server.info"
2016/11/26 11:29:55 [error] 24345#0: *2920 connect() to unix:/home/deployer/api/shared/tmp/sockets/unicorn.sock failed (111: Connection refused) while connecting to upstream, client: 66.249.76.78, server: api.server.info, request: "GET /companies/7703270067-135ce8fc-278c-4213-ace1-61ad80b0f092/claims?show_only=solved HTTP/1.1", upstream: "http://unix:/home/deployer/api/shared/tmp/sockets/unicorn.sock:/companies/7703270067-135ce8fc-278c-4213-ace1-61ad80b0f092/claims?show_only=solved", host: "api.server.info"
2016/11/26 11:32:25 [error] 24343#0: *2924 connect() to unix:/home/deployer/api/shared/tmp/sockets/unicorn.sock failed (111: Connection refused) while connecting to upstream, client: 66.249.76.120, server: server.info, request: "GET /robots.txt HTTP/1.1", upstream: "http://unix:/home/deployer/api/shared/tmp/sockets/unicorn.sock:/robots.txt", host: "server.info"
2016/11/26 11:32:25 [error] 24343#0: *2926 connect() to unix:/home/deployer/api/shared/tmp/sockets/unicorn.sock failed (111: Connection refused) while connecting to upstream, client: 66.249.64.27, server: server.info, request: "GET /companies/7724261610-181a0690-4d45-454a-b9f6-a038cf4dc29d/certificates HTTP/1.1", upstream: "http://unix:/home/deployer/api/shared/tmp/sockets/unicorn.sock:/companies/7724261610-181a0690-4d45-454a-b9f6-a038cf4dc29d/certificates", host: "server.info"
2016/11/26 11:33:17 [error] 24343#0: *2928 connect() to unix:/home/deployer/api/shared/tmp/sockets/unicorn.sock failed (111: Connection refused) while connecting to upstream, client: 66.249.76.118, server: server.info, request: "GET /companies/2310031475-5dc7ac1b-4723-438a-b795-4ee219637197 HTTP/1.1", upstream: "http://unix:/home/deployer/api/shared/tmp/sockets/unicorn.sock:/companies/2310031475-5dc7ac1b-4723-438a-b795-4ee219637197", host: "server.info"
2016/11/26 11:33:56 [error] 24343#0: *2930 connect() to unix:/home/deployer/api/shared/tmp/sockets/unicorn.sock failed (111: Connection refused) while connecting to upstream, client: 157.55.39.174, server: server.info, request: "GET /companies/2310031475-05c0ae62-b441-42df-873d-9b301fd3fb48/contacts HTTP/1.1", upstream: "http://unix:/home/deployer/api/shared/tmp/sockets/unicorn.sock:/companies/2310031475-05c0ae62-b441-42df-873d-9b301fd3fb48/contacts", host: "server.info"
2016/11/26 11:34:17 [error] 24342#0: *2932 connect() to unix:/home/deployer/api/shared/tmp/sockets/unicorn.sock failed (111: Connection refused) while connecting to upstream, client: 157.55.39.174, server: server.info, request: "GET /companies/5036045205-91472316-e872-4b1c-bc84-f11581310120/claims/328 HTTP/1.1", upstream: "http://unix:/home/deployer/api/shared/tmp/sockets/unicorn.sock:/companies/5036045205-91472316-e872-4b1c-bc84-f11581310120/claims/328", host: "server.info"
2016/11/26 11:34:55 [error] 24342#0: *2934 connect() to unix:/home/deployer/api/shared/tmp/sockets/unicorn.sock failed (111: Connection refused) while connecting to upstream, client: 66.249.76.118, server: server.info, request: "GET /companies/164705052790/certificates HTTP/1.1", upstream: "http://unix:/home/deployer/api/shared/tmp/sockets/unicorn.sock:/companies/164705052790/certificates", host: "server.info"
2016/11/26 11:37:04 [error] 24342#0: *2938 connect() to unix:/home/deployer/api/shared/tmp/sockets/unicorn.sock failed (111: Connection refused) while connecting to upstream, client: 157.55.39.88, server: server.info, request: "GET /companies/2310031475-8c540868-cd78-4063-a867-d690ea80eab0/employees HTTP/1.1", upstream: "http://unix:/home/deployer/api/shared/tmp/sockets/unicorn.sock:/companies/2310031475-8c540868-cd78-4063-a867-d690ea80eab0/employees", host: "server.info" |
|
error.log nginx на внутреннем сервере
| Code | 1
2
3
4
5
6
7
8
9
| 2016/11/26 11:37:02 [warn] 1105#0: *746 an upstream response is buffered to a temporary file /var/cache/nginx/proxy_temp/5/13/0000000135 while reading upstream, client: 10.1.1.12, server: _, request: "GET / HTTP/1.0", upstream: "http://unix:/home/deployer/shared/tmp/sockets/unicorn.sock:/", host: "server.info"
2016/11/26 11:41:29 [warn] 1105#0: *750 an upstream response is buffered to a temporary file /var/cache/nginx/proxy_temp/6/13/0000000136 while reading upstream, client: 10.1.1.12, server: _, request: "GET / HTTP/1.0", upstream: "http://unix:/home/deployer/shared/tmp/sockets/unicorn.sock:/", host: "www.server.info", referrer: "http://www.server.info"
2016/11/26 11:41:30 [warn] 1105#0: *752 an upstream response is buffered to a temporary file /var/cache/nginx/proxy_temp/7/13/0000000137 while reading upstream, client: 10.1.1.12, server: _, request: "GET / HTTP/1.0", upstream: "http://unix:/home/deployer/shared/tmp/sockets/unicorn.sock:/", host: "www.server.info"
2016/11/26 11:41:36 [warn] 1104#0: *794 an upstream response is buffered to a temporary file /var/cache/nginx/proxy_temp/8/13/0000000138 while reading upstream, client: 10.1.1.12, server: _, request: "GET /companies HTTP/1.0", upstream: "http://unix:/home/deployer/shared/tmp/sockets/unicorn.sock:/companies", host: "www.server.info", referrer: "http://www.server.info/companies"
2016/11/26 11:41:36 [warn] 1104#0: *800 an upstream response is buffered to a temporary file /var/cache/nginx/proxy_temp/9/13/0000000139 while reading upstream, client: 10.1.1.12, server: _, request: "GET /companies HTTP/1.0", upstream: "http://unix:/home/deployer/shared/tmp/sockets/unicorn.sock:/companies", host: "www.server.info"
2016/11/26 11:41:38 [warn] 1104#0: *824 an upstream response is buffered to a temporary file /var/cache/nginx/proxy_temp/0/14/0000000140 while reading upstream, client: 10.1.1.12, server: _, request: "GET / HTTP/1.0", upstream: "http://unix:/home/deployer/shared/tmp/sockets/unicorn.sock:/", host: "www.server.info", referrer: "http://www.server.info/"
2016/11/26 11:41:39 [warn] 1104#0: *828 an upstream response is buffered to a temporary file /var/cache/nginx/proxy_temp/1/14/0000000141 while reading upstream, client: 10.1.1.12, server: _, request: "GET / HTTP/1.0", upstream: "http://unix:/home/deployer/shared/tmp/sockets/unicorn.sock:/", host: "www.server.info"
2016/11/26 11:41:40 [warn] 1104#0: *834 an upstream response is buffered to a temporary file /var/cache/nginx/proxy_temp/2/14/0000000142 while reading upstream, client: 10.1.1.12, server: _, request: "GET /claims HTTP/1.0", upstream: "http://unix:/home/deployer/shared/tmp/sockets/unicorn.sock:/claims", host: "www.server.info", referrer: "http://www.server.info/claims"
2016/11/26 11:41:41 [warn] 1104#0: *840 an upstream response is buffered to a temporary file /var/cache/nginx/proxy_temp/3/14/0000000143 while reading upstream, client: 10.1.1.12, server: _, request: "GET /claims HTTP/1.0", upstream: "http://unix:/home/deployer/shared/tmp/sockets/unicorn.sock:/claims", host: "www.server.info" |
|
/home/deployer/current/log/unicorn.stderr.log
| Code | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| I, [2016-11-26T03:05:17.273717 #893] INFO -- : unlinking existing socket=/home/deployer/shared/tmp/sockets/unicorn.sock
I, [2016-11-26T03:05:17.274281 #893] INFO -- : listening on addr=/home/deployer/shared/tmp/sockets/unicorn.sock fd=14
I, [2016-11-26T03:05:17.274468 #893] INFO -- : listening on addr=0.0.0.0:8087 fd=15
I, [2016-11-26T03:05:17.282013 #2005] INFO -- : worker=0 ready
I, [2016-11-26T03:05:17.285332 #2008] INFO -- : worker=1 ready
I, [2016-11-26T03:05:17.289500 #2011] INFO -- : worker=2 ready
I, [2016-11-26T03:05:17.292579 #2014] INFO -- : worker=3 ready
I, [2016-11-26T03:05:17.295932 #2017] INFO -- : worker=4 ready
I, [2016-11-26T03:05:17.299011 #2020] INFO -- : worker=5 ready
I, [2016-11-26T03:05:17.302195 #2023] INFO -- : worker=6 ready
I, [2016-11-26T03:05:17.305498 #2026] INFO -- : worker=7 ready
I, [2016-11-26T03:05:17.309347 #893] INFO -- : master process ready
I, [2016-11-26T03:05:17.309675 #2029] INFO -- : worker=8 ready
I, [2016-11-26T03:05:17.312576 #2032] INFO -- : worker=9 ready
X-Accel-Mapping header missing
......
X-Accel-Mapping header missing
E, [2016-11-26T09:27:38.568021 #893] ERROR -- : worker=9 PID:2032 timeout (121s > 120s), killing
E, [2016-11-26T09:27:38.582953 #893] ERROR -- : reaped #<Process::Status: pid 2032 SIGKILL (signal 9)> worker=9
I, [2016-11-26T09:27:38.617721 #6779] INFO -- : worker=9 ready |
|
настройки nginx для домена api.server.info (10.1.1.12)
| Code | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
| upstream mainapp {
server unix:/home/deployer/api/shared/tmp/sockets/unicorn.sock fail_timeout=0;
}
server {
listen 443 ssl;
server_name api.server.info;
ssl on;
ssl_certificate /etc/letsencrypt/live/api.server.info/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/api.server.info/privkey.pem;
include ssl_params;
charset utf-8;
client_max_body_size 0;
set $app_root_path /home/deployer/api/;
access_log /var/log/nginx/api.access.log;
root $app_root_path/current/public;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
#pass to the upstream unicorn server mentioned above
proxy_pass [url]http://mainapp;[/url]
}
location ~ ^/uploads/ {
root $app_root_path/current/public;
gzip_static on;
expires max;
add_header Cache-Control public;
# access_log /dev/null;
}
}
server {
listen 80;
server_name api.server.info;
rewrite ^ https://api.server.info$request_uri? permanent;
} |
|
настройки nginx на внутреннем сервере (10.1.1.11), обрабатывающий запросы
| Code | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
| upstream mainapp {
server unix:/home/deployer/shared/tmp/sockets/unicorn.sock;
}
server {
listen 80 default deferred;
server_name _;
charset utf-8;
client_max_body_size 0;
set $app_root_path /home/deployer/;
access_log /var/log/nginx/mainapp.access.log;
root /home/deployer/current/public;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
#pass to the upstream unicorn server mentioned above
proxy_pass http://mainapp;
}
location ~ ^/assets/ {
root $app_root_path/current/public;
gzip_static on;
expires max;
add_header Cache-Control public;
# access_log /dev/null;
}
} |
|
на внешнем сервере
ls -l /home/deployer/api/shared/tmp/sockets/unicorn.sock
srwxrwxrwx 1 deployer deployer 0 май 14 2016 /home/deployer/api/shared/tmp/sockets/unicorn.sock
на внутреннем сервере
ls -l /home/deployer/shared/tmp/sockets/unicorn.sock
srwxrwxrwx 1 deployer deployer 0 ноя 26 03:05 /home/deployer/shared/tmp/sockets/unicorn.sock
less /home/deployer/current/config/unicorn/production.rb
| Code | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
| worker_processes 10
working_directory "/home/deployer/current" # available in 0.94.0+
listen "/home/deployer/shared/tmp/sockets/unicorn.sock", :backlog => 64
listen 8087, :tcp_nopush => true
timeout 120
pid "/home/deployer/shared/tmp/pids/unicorn.pid"
stderr_path "/home/deployer/shared/log/unicorn.stderr.log"
stdout_path "/home/deployer/shared/log/unicorn.stdout.log"
preload_app true
GC.respond_to?(:copy_on_write_friendly=) and
GC.copy_on_write_friendly = true
check_client_connection false
before_fork do |server, worker|
# the following is highly recomended for Rails + "preload_app true"
# as there's no need for the master process to hold a connection
defined?(ActiveRecord::Base) and
ActiveRecord::Base.connection.disconnect!
old_pid = "#{server.config[:pid]}.oldbin"
if old_pid != server.pid
begin
sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU
Process.kill(sig, File.read(old_pid).to_i)
rescue Errno::ENOENT, Errno::ESRCH
end
end
end
after_fork do |server, worker|
# per-process listener ports for debugging/admin/migrations
# addr = "127.0.0.1:#{9293 + worker.nr}"
# server.listen(addr, :tries => -1, :delay => 5, :tcp_nopush => true)
# the following is *required* for Rails + "preload_app true",
defined?(ActiveRecord::Base) and
ActiveRecord::Base.establish_connection
# if preload_app is true, then you may also want to check and
# restart any other shared sockets/descriptors such as Memcached,
# and Redis. TokyoCabinet file handles are safe to reuse
# between any number of forked children (assuming your kernel
# correctly implements pread()/pwrite() system calls)
end |
|
0
|