2016-03-04 48 views
0

问题是我们的站点周期性地为存在的路由呈现404路由错误异常;甚至根本路线。Rails 4.0.0遇到了现有路由的周期性路由错误异常(404)

这个问题似乎在一天中最繁忙的部分出现。如果刷新页面,页面可能会适当渲染,或者可能不适合。

如果彪马刷新,问题暂时解除。

对于实际存在的路由,这些404例外的美洲狮日志对于实际上不存在的路由发生的404例外完全相同。一个例子日志低于:

ActionController::RoutingError (No route matches [GET] : "/app" 
    actionpack (4.0.11.1) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call' 
    actionpack (4.0.11.1) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call' 
    railties (4.0.11.1) lib/rails/rack/logger.rb:38:in `call_app' 
    railties (4.0.11.1) lib/rails/rack/logger.rb:22:in `call' 
    request_store (1.1.0) lib/request_store/middleware.rb:8:in `call' 
    actionpack (4.0.11.1) lib/action_dispatch/middleware/request_id.rb:21:in `call' 
    rack (1.5.5) lib/rack/methodoverride.rb:21:in `call' 
    rack (1.5.5) lib/rack/runtime.rb:17:in `call' 
    activesupport (4.0.11.1) lib/active_support/cache/strategy/local_cache.rb:83:in `call' 
    rack (1.5.5) lib/rack/sendfile.rb:112:in `call' 
    railties (4.0.11.1) lib/rails/engine.rb:511:in `call' 
    railties (4.0.11.1) lib/rails/application.rb:97:in `call' 
    puma (2.15.3) lib/puma/configuration.rb:79:in `call' 
    puma (2.15.3) lib/puma/server.rb:541:in `handle_request' 
    puma (2.15.3) lib/puma/server.rb:388:in `process_client' 
    puma (2.15.3) lib/puma/server.rb:270:in `block in run' 
    puma (2.15.3) lib/puma/thread_pool.rb:106:in `call' 
    puma (2.15.3) lib/puma/thread_pool.rb:106:in `block in spawn_thread' 

这条航线确实存在,但服务器仍呈现404请求。

我不知道发生了什么,所以我在下面包含了服务器的配置。

常规服务器信息

的Ubuntu 14.04

Nginx的1.4.7

彪马2.15.3

的Ruby 2.2.0

Rails的4.0.11.1

Nginx的配置

user www-data; 
worker_processes 4; 
pid /run/nginx.pid; 

events { 
    worker_connections 1024; 
} 

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/*; 
} 

Nginx的虚拟主机配置

upstream puma { 
    server unix:/tmp/puma.sock; 
} 

server { 
    listen 80 default deferred default_server; 

    root /home/deployer/deploys/current/public; 

    if ($http_host ~* domain.com) { 
    return 301 https://$host$request_uri$is_args$args; 
    } 

    location ^~ /assets/ { 
    gzip_static on; 
    expires max; 
    add_header Cache-Control public; 
    proxy_set_header X-Forwarded-Proto https; 
    } 

    try_files $uri/index.html $uri @puma; 

    location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|mp3|flv|mpeg|avi|svg)$ { 
    try_files $uri @puma; 
    } 

    location @puma { 
    proxy_headers_hash_max_size 51200; 
    proxy_headers_hash_bucket_size 6400; 
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
    proxy_set_header X-Forwarded-Proto http; 
    proxy_set_header X-Forwarded-Ssl off; 
    proxy_set_header Host $http_host; 
    proxy_redirect off; 
    proxy_read_timeout 250; #4 minutes 
    proxy_pass http://puma; 
    proxy_set_header X-Forwarded-Proto https; 
    } 

    error_page 500 502 503 504 /500.html; 
    client_max_body_size 4G; 
    keepalive_timeout 60; 
} 

server { 
    listen 443 default_server ssl; 
    server_name _; 

    ssl     on; 
    ssl_protocols TLSv1.2 TLSv1.1 TLSv1; 
    ssl_certificate  /home/deployer/ssl/tld/domain.chained.crt; 
    ssl_certificate_key /home/deployer/ssl/tld/domain.key; 

    root /home/deployer/deploys/current/public; 

    if ($http_host !~* domain.com) { 
    return 301 http://$host$request_uri$is_args$args; 
    } 

    location ^~ /assets/ { 
    gzip_static on; 
    expires max; 
    add_header Cache-Control public; 
    proxy_set_header X-Forwarded-Proto https; 
    } 

    try_files $uri/index.html $uri @puma; 

    location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|mp3|flv|mpeg|avi|svg)$ { 
    try_files $uri @puma; 
    } 

    location @puma { 
    proxy_headers_hash_max_size 51200; 
    proxy_headers_hash_bucket_size 6400; 
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
    proxy_set_header X-Forwarded-Proto https; 
    proxy_set_header X-Forwarded-Ssl on; 
    proxy_set_header Host $http_host; 
    proxy_redirect off; 
    proxy_read_timeout 250; #4 minutes 
    proxy_pass http://puma; 
    proxy_set_header X-Forwarded-Proto https; 
    } 

    error_page 500 502 503 504 /500.html; 
    client_max_body_size 4G; 
    keepalive_timeout 60; 
} 

彪马配置(配置/ puma.rb)

workers Integer(4) 
threads 12, 12 

port  ENV['PORT']  || 3000 
environment ENV['RACK_ENV'] || 'development' 

彪马部署经由Capistrano的

exec su - deployer -c 'cd /home/deployer/deploys/releases/20160303234701; export PORT=5000; export RAILS_ENV=production; export PUMA_WORKERS=4; bundle exec puma -e $RAILS_ENV --pidfile /tmp/puma.pid -C config/puma.rb -b unix:///tmp/puma.sock >> /var/log/domain-service/web-1.log 2>&1' 
+0

让我们看看你的routes.rb – infused

回答

0

这可以追溯到reload_routes的调用!在我们的控制器之一。