首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Rails 4.2应用程序在虚拟私有服务器上空闲2-3小时后不会响应

Rails 4.2应用程序在虚拟私有服务器上空闲2-3小时后不会响应
EN

Stack Overflow用户
提问于 2020-05-25 03:43:19
回答 1查看 56关注 0票数 1

我正试图在upcloud上设置我的虚拟私有服务器。我使用的是PUMA 4.3和ruby 2.4.2和rails 4.2.8。我的美洲豹配置是

代码语言:javascript
复制
threads_count = Integer(ENV['RAILS_MAX_THREADS'] || 5)
threads threads_count, threads_count

preload_app!

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

on_worker_boot do
  # Worker specific setup for Rails 4.1+
  # See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot
  ActiveRecord::Base.establish_connection
end

我的Nginx配置是

代码语言:javascript
复制
        worker_connections 768;
        # multi_accept on;
}

http {

        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 36000s;
        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;

        ##
        # SSL Settings
        ##

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
        ssl_prefer_server_ciphers on;

最后,我的example.com.conf文件是

代码语言:javascript
复制
upstream my_app {
  server unix:///var/run/my_app.sock;
}

server {
  listen 80;
  server_name 94.237.52.251:443; # change to match your URL
  root /soop/soup; # I assume your app is located at that location

  location / {
    proxy_pass http://94.237.52.251:443; # match the name of upstream directive which is defined above
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }

  location ~* ^/assets/ {
    # Per RFC2616 - 1 year maximum expiry
    expires 1y;
    add_header Cache-Control public;

    # Some browsers still send conditional-GET requests if there's a
    # Last-Modified header or an ETag header even if they haven't
    # reached the expiry date sent in the Expires header.
    add_header Last-Modified "";
    add_header ETag "";
    break;
  }
}

我必须在每15-20分钟空闲时间后重新启动rails服务器,或者每次从VPS断开之后,浏览器都会显示94.237.52.251需要很长时间才能响应。目前无法处理此请求。HTTP错误500我面临这个问题已经一个星期了。请帮帮我。

EN

回答 1

Stack Overflow用户

发布于 2020-05-25 08:15:01

将您的keepalive_timeout 36000s;更改为75

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61995422

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档