长时间运行后,日志中的Nginx + Passenger + Rails HTTP 499

时间:2016-11-02 13:34:28

标签: ruby-on-rails nginx passenger

我的NGINX + Passenger + Rails设置存在问题。一个请求需要永远运行并且不会被取消。我不确定是什么原因,我的error.log文件中没有错误。

令人惊讶的是,如果我作为网络服务器切换到Puma,一切正常。

在我的应用程序中导致问题的代码标有注释:

  def build_redirect_url
    raise ArgumentError.new("not implemented for provider") if checkout_settings[:package_provider] != "expedia_click_and_mix"
    opts = {
      :hotels            => [hotel],
      :from_date         => from_date,
      :to_date           => to_date,
      :from_airport_code => from_airport.code,
      :to_airport_code   => to_airport.code,
      :number_of_adults  => number_of_adults.to_i,
      :cache             => false,
      :piid              => checkout_settings[:unique_identifier]
    }
    # the below line never finishes. takes like 30 seconds
    searcher    = PackageKraken::ListKraken::HotelGrouper.new(opts)
    details_url = searcher.search.first.details_url
    filter_id   = search_filter_setting.id
    build_filter_redirect_url(filter_id, "expedia_click_and_mix", hotel.id, details_url)
  end

我们从未超越searcher =行。似乎这个过程在此之前消失了。所以我所做的是检查我的nginx日志文件中的问题,但我只有这个。不管它似乎有499错误代码。

这就是我在日志文件中的内容:

79.236.111.56 - - [02/Nov/2016:14:28:30 +0100] "GET /packages/package_redirect_url?checkout_settings=%7B%22package_identifier%22%3A%22v5-8a5c783c4b614f2d8018117d4c7fa1f5-8-8-1%22
%2C%22package_provider%22%3A%22expedia_click_and_mix%22%7D&from_airport_id=b2ccff00-2186-482e-a74f-6892c8fd7f77&from_date=2016-11-09+01%3A00%3A00+%2B0100&hotel_id=14245&number_of
_adults=1&to_airport_id=aabc5cd4-36e6-45c9-b027-e0ed4b209414&to_date=2016-11-15+01%3A00%3A00+%2B0100 HTTP/1.1" 499 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWeb
Kit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36"

以下是我对该网站的网站配置:

server {
  listen 80;
  server_name tripl.de www.tripl.de;
  return 301 https://$host$request_uri;
}

server {
  listen 443;
  server_name tripl.de;
  ssl on;
  ssl_certificate /etc/nginx/ssl/wildcard-cert.crt;
  ssl_certificate_key /etc/nginx/ssl/wildcard-cert.key;
  return 301 https://www.tripl.de$request_uri;
}

# Production server
server {
  proxy_connect_timeout       600;
  proxy_send_timeout          600;
  proxy_read_timeout          600;
  send_timeout                600;
  listen 443;
  server_name www.tripl.de;
  ssl on;
  ssl_certificate /etc/nginx/ssl/wildcard-cert.crt;
  ssl_certificate_key /etc/nginx/ssl/wildcard-cert.key;

  client_max_body_size 4G;
  keepalive_timeout 60;
  passenger_enabled on;
  root         /home/deployer/app_production/current/public;
  proxy_set_header        X-Forwarded-Proto https;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
location / {
     if ($request_method = 'OPTIONS') {
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
        #
        # Custom headers and headers various browsers *should* be OK with but aren't
        #
        add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
        #
        # Tell client that this pre-flight info is valid for 20 days
        #
        add_header 'Access-Control-Max-Age' 1728000;
        add_header 'Content-Type' 'text/plain charset=UTF-8';
        add_header 'Content-Length' 0;
        return 204;
     }
     if ($request_method = 'POST') {
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
        add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
     }
     if ($request_method = 'GET') {
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
        add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
     }
}

}

这就是我passenger.conf中的内容:

passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;
passenger_ruby /home/deployer/.rbenv/shims/ruby;

任何想法可能出错?

由于

1 个答案:

答案 0 :(得分:1)

问题是我在某些地区使用Celluloid。显然乘客不喜欢产生新线程。