我正在努力解决' 504网关超时问题。在我的rails网站上的Digitalocean问题。我重置了DO droplet的root密码后,我开始面对这个错误。
请参阅下面的unicorn.log
from /usr/local/rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /home/rails/first_app/config/boot.rb:3:in `<top (required)>'
from /home/rails/first_app/config/application.rb:1:in `require_relative'
from /home/rails/first_app/config/application.rb:1:in `<top (required)>'
from /home/rails/first_app/config/environment.rb:2:in `require_relative'
from /home/rails/first_app/config/environment.rb:2:in `<top (required)>'
from config.ru:4:in `require_relative'
from config.ru:4:in `block in <main>'
from /usr/local/rvm/gems/ruby-2.3.1/gems/rack-2.0.3/lib/rack/builder.rb:55:in `instance_eval'
from /usr/local/rvm/gems/ruby-2.3.1/gems/rack-2.0.3/lib/rack/builder.rb:55:in `initialize'
from config.ru:1:in `new'
from config.ru:1:in `<main>'
from /usr/local/rvm/gems/ruby-2.3.1/gems/unicorn-5.3.0/lib/unicorn.rb:56:in `eval'
from /usr/local/rvm/gems/ruby-2.3.1/gems/unicorn-5.3.0/lib/unicorn.rb:56:in `block in builder'
from /usr/local/rvm/gems/ruby-2.3.1/gems/unicorn-5.3.0/lib/unicorn/http_server.rb:796:in `build_app!'
from /usr/local/rvm/gems/ruby-2.3.1/gems/unicorn-5.3.0/lib/unicorn/http_server.rb:661:in `init_worker_process'
from /usr/local/rvm/gems/ruby-2.3.1/gems/unicorn-5.3.0/lib/unicorn/http_server.rb:683:in `worker_loop'
from /usr/local/rvm/gems/ruby-2.3.1/gems/unicorn-5.3.0/lib/unicorn/http_server.rb:549:in `spawn_missing_workers'
from /usr/local/rvm/gems/ruby-2.3.1/gems/unicorn-5.3.0/lib/unicorn/http_server.rb:563:in `maintain_worker_count'
from /usr/local/rvm/gems/ruby-2.3.1/gems/unicorn-5.3.0/lib/unicorn/http_server.rb:293:in `join'
from /usr/local/rvm/gems/ruby-2.3.1/gems/unicorn-5.3.0/bin/unicorn:126:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.3.1/bin/unicorn:23:in `load'
from /usr/local/rvm/gems/ruby-2.3.1/bin/unicorn:23:in `<main>'
from /usr/local/rvm/gems/ruby-2.3.1@global/bin/ruby_executable_hooks:15:in `eval'
from /usr/local/rvm/gems/ruby-2.3.1@global/bin/ruby_executable_hooks:15:in `<main>'
E, [2017-12-27T21:10:44.611839 #20975] ERROR -- : reaped #<Process::Status: pid 2628 exit 1> worker=1
I, [2017-12-27T21:10:44.611988 #20975] INFO -- : worker=1 spawning...
I, [2017-12-27T21:10:44.614844 #2640] INFO -- : worker=1 spawned pid=2640
I, [2017-12-27T21:10:44.638040 #2640] INFO -- : Refreshing Gem list
这是我的nginx / error.log
2017/12/27 21:11:15 [error] 21320#0: *14 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 106.203.174.245, server: mysite.com, request: "GET / HTTP/1.1", upstream: "http://unix:/var/run/unicorn.sock/", host: "mysite.com"
请让我知道我应该分享哪些细节,以及如何解决此问题。
非常感谢。
[评论后编辑]
这是ps -ef |的结果grep独角兽
root 20975 1 0 Dec27 ? 00:01:45 unicorn master -D -c /etc/unicorn.conf -E production `rails 24881 20975 15 03:16 ? 00:00:00 unicorn worker[0] -D -c /etc/unicorn.conf -E production`
rails 24884 20975 0 03:16 ? 00:00:00 unicorn worker[1] -D -c /etc/unicorn.conf -E production
root 24887 20975 0 03:16 ? 00:00:00 unicorn worker[2] -D -c /etc/unicorn.conf -E production
root 24890 20975 0 03:16 ? 00:00:00 unicorn worker[3] -D -c /etc/unicorn.conf -E production
prativi+ 24894 24669 0 03:16 pts/0 00:00:00 grep --color=auto unicorn
[新编辑]
sudo nano /etc/unicorn.conf
listen "unix:/var/run/unicorn.sock"
worker_processes 4
user "rails"
working_directory "/home/rails/first_app"
pid "/var/run/unicorn.pid"
stderr_path "/var/log/unicorn/unicorn.log"
stdout_path "/var/log/unicorn/unicorn.log"
sudo nano etc / nginx / nginx.conf
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 60s;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##
#include /etc/nginx/naxsi_core.rules;
##
# nginx-passenger config
##
# Uncomment it if you installed nginx-passenger
##
#passenger_root /usr;
#passenger_ruby /usr/bin/ruby;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}
PS:我无法在我的rails应用程序中找到config / unicorn.rb。