服务器 Ruby on Rails + unicorn + nginx 停止响应

编程入门 行业动态 更新时间:2024-10-27 10:29:13
本文介绍了服务器 Ruby on Rails + unicorn + nginx 停止响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我的服务器 Rails 工作正常,但 10 分钟后没有请求,它的响应是一个坏网关.我真的认为我的配置是有序的,但它不起作用.我没有更多的想法会发生什么.

My server Rails worker normally, but after 10 minutes without a request its response is a bad gateway. I really think my configurations are in order, but it don't work. I don't have more ideas what to is happening.

我的配置:

unicorn.rb:

unicorn.rb:

@dir = File.expand_path(File.dirname(__FILE__)) + "/.." worker_processes 2 working_directory @dir timeout 10 listen File.join('/tmp/nutrimais.sock') listen File.join('/tmp/nutrimais_2.sock') preload_app true# if ENV['RAILS_ENV'] != 'development' GC.respond_to?(:copy_on_write_friendly=) and GC.copy_on_write_friendly = true check_client_connection false before_fork do |server, worker| Signal.trap 'TERM' do puts 'Unicorn master intercepting TERM and sending myself QUIT instead' Process.kill 'QUIT', Process.pid end defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect! end after_fork do |server, worker| Signal.trap 'TERM' do puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT' end defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection end

nginx 配置:

upstream nutrimais { # Path to Puma SOCK file, as defined previously server unix:/tmp/nutrimais.sock max_fails=2 fail_timeout=10s; server unix:/tmp/nutrimais_2.sock; } server { listen 80; server_name dev.nutrimais.br; location / { autoindex on; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $host; # time out settings proxy_next_upstream http_502 timeout; proxy_next_upstream_timeout 0; proxy_next_upstream_tries 0; proxy_connect_timeout 159s; proxy_send_timeout 600; proxy_read_timeout 600; proxy_buffer_size 64k; proxy_buffers 16 32k; proxy_busy_buffers_size 64k; proxy_temp_file_write_size 64k; proxy_pass_header Set-Cookie; proxy_redirect off; proxy_hide_header Vary; proxy_set_header Accept-Encoding ''; proxy_ignore_headers Cache-Control Expires; proxy_set_header Referer $http_referer; proxy_set_header Host $host; proxy_set_header Cookie $http_cookie; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Server $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass nutrimais; } }

宝石文件:

source 'rubygems' gem 'rails', '4.2.4' gem 'unicorn-rails', '~> 2.2' gem 'pg' gem 'mysql2', '~> 0.3.18' gem 'sass-rails', '~> 5.0' gem 'uglifier', '>= 1.3.0' gem 'coffee-rails', '~> 4.1.0' gem 'duktape' gem 'jquery-rails' gem 'turbolinks' gem 'jbuilder', '~> 2.0' gem 'bootstrap-sass' gem 'devise' gem 'simple_form' gem 'minitest' gem "paperclip", "~> 4.3" gem 'aws-sdk', '< 2.0' gem 'mail_form', '~> 1.5.0.rc' gem 'sendgrid-ruby' gem 'zopim_rails' gem 'meta-tags' gem 'ckeditor' gem 'slick_rails' group :development do gem 'better_errors' gem 'binding_of_caller', :platforms=>[:mri_20] gem 'quiet_assets' gem 'rails_layout' gem 'spring-commands-rspec' gem 'web-console', '~> 2.0' gem 'spring' end group :production do gem 'therubyracer' end group :development, :test do gem 'factory_girl_rails' gem 'faker' gem 'pry-rails' gem 'pry-rescue' gem 'rspec-rails' gem 'rubocop' gem 'byebug' end group :test do gem 'capybara' gem 'database_cleaner' gem 'launchy' gem 'selenium-webdriver' end

登录时给出坏网关:

Started GET "/menus" for 127.0.0.1 at 2016-01-20 17:25:17 +0000 I, [2016-01-20T17:25:17.580380 #9] INFO -- : Processing by MenusController#index as HTML D, [2016-01-20T17:25:17.904933 #9] DEBUG -- : [1m[36mMenu Load (322.3ms)[0m [1mSELECT `menus`.* FROM `menus` ORDER BY created_at DESC[0m I, [2016-01-20T17:25:20.006674 #9] INFO -- : Started GET "/menus" for 127.0.0.1 at 2016-01-20 17:25:20 +0000

它停留在 Started GET 而不是什么都不做

It stays in Started GET and not does nothing

推荐答案

我发现发生了什么,linux 防火墙终止了连接.当我将数据库放在同一台机器上时,它可以正常工作.

I discovery what was happening, the linux firewall killed the connection. When I put the database in the same machine it is worked without trumbles.

更多推荐

服务器 Ruby on Rails + unicorn + nginx 停止响应

本文发布于:2023-10-26 17:10:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1530786.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:服务器   Ruby   Rails   unicorn   nginx

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!