【问题标题】:Thin server not working on Production mode(live) on Amazon Ec2瘦服务器无法在 Amazon Ec2 上的生产模式(实时)下运行
【发布时间】:2014-03-09 02:09:56
【问题描述】:

我正在运行一个使用 angularjs 作为前端的 Rails 应用程序。

我刚刚将它投入生产,但是我遇到了一个非常奇怪的问题。

我在 Amazon EC2(Ubuntu 64 位机器)上使用了瘦服务器和 Nginx 服务器。

这样做时,我遇到的问题是瘦服务器在给定时间(1-5 分钟)后停止。这发生在现场网站上。

我生成的日志文件如下:-

>> Thin web server (v1.5.1 codename Straight Razor)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:3000, CTRL+C to stop
>> Exiting!
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/eventmachine-1.0.3/lib/em/pure_ruby.rb:578:in `write_nonblock': Broken pipe (Errno::EPIPE)
    from /usr/local/rvm/gems/ruby-1.9.3-p484/gems/eventmachine-1.0.3/lib/em/pure_ruby.rb:578:in `eventable_write'
    from /usr/local/rvm/gems/ruby-1.9.3-p484/gems/eventmachine-1.0.3/lib/em/pure_ruby.rb:368:in `block in crank_selectables'
    from /usr/local/rvm/gems/ruby-1.9.3-p484/gems/eventmachine-1.0.3/lib/em/pure_ruby.rb:368:in `each'
    from /usr/local/rvm/gems/ruby-1.9.3-p484/gems/eventmachine-1.0.3/lib/em/pure_ruby.rb:368:in `crank_selectables'
    from /usr/local/rvm/gems/ruby-1.9.3-p484/gems/eventmachine-1.0.3/lib/em/pure_ruby.rb:324:in `block in run'
    from /usr/local/rvm/gems/ruby-1.9.3-p484/gems/eventmachine-1.0.3/lib/em/pure_ruby.rb:318:in `loop'
    from /usr/local/rvm/gems/ruby-1.9.3-p484/gems/eventmachine-1.0.3/lib/em/pure_ruby.rb:318:in `run'
    from /usr/local/rvm/gems/ruby-1.9.3-p484/gems/eventmachine-1.0.3/lib/em/pure_ruby.rb:62:in `run_machine'
    from /usr/local/rvm/gems/ruby-1.9.3-p484/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run'
    from /usr/local/rvm/gems/ruby-1.9.3-p484/gems/thin-1.5.1/lib/thin/backends/base.rb:63:in `start'
    from /usr/local/rvm/gems/ruby-1.9.3-p484/gems/thin-1.5.1/lib/thin/server.rb:159:in `start'
    from /usr/local/rvm/gems/ruby-1.9.3-p484/gems/thin-1.5.1/lib/thin/controllers/controller.rb:86:in `start'
    from /usr/local/rvm/gems/ruby-1.9.3-p484/gems/thin-1.5.1/lib/thin/runner.rb:187:in `run_command'
    from /usr/local/rvm/gems/ruby-1.9.3-p484/gems/thin-1.5.1/lib/thin/runner.rb:152:in `run!'
    from /usr/local/rvm/gems/ruby-1.9.3-p484/gems/thin-1.5.1/bin/thin:6:in `<top (required)>'
    from /usr/local/rvm/gems/ruby-1.9.3-p484/bin/thin:23:in `load'
    from /usr/local/rvm/gems/ruby-1.9.3-p484/bin/thin:23:in `<main>'
    from /usr/local/rvm/gems/ruby-1.9.3-p484/bin/ruby_executable_hooks:15:in `eval'
    from /usr/local/rvm/gems/ruby-1.9.3-p484/bin/ruby_executable_hooks:15:in `<main>'
>> Writing PID to tmp/pids/thin.3000.pid
>> Using rack adapter
You did not specify how you would like Rails to report deprecation notices for your Production environment, please set config.active_support.deprecation to :log, :notify or :stderr at config/environments/Production.rb
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/eventmachine-1.0.3/lib/em/pure_ruby.rb:256: warning: already initialized constant TimerFired
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/eventmachine-1.0.3/lib/em/pure_ruby.rb:258: warning: already initialized constant ConnectionData
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/eventmachine-1.0.3/lib/em/pure_ruby.rb:260: warning: already initialized constant ConnectionUnbound
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/eventmachine-1.0.3/lib/em/pure_ruby.rb:262: warning: already initialized constant ConnectionAccepted
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/eventmachine-1.0.3/lib/em/pure_ruby.rb:264: warning: already initialized constant ConnectionCompleted
/usr/local/rvm/gems/ruby-1.9.3-p484/gems/eventmachine-1.0.3/lib/em/pure_ruby.rb:266: warning: already initialized constant LoopbreakSignalled
        SECURITY WARNING: No secret option provided to Rack::Session::Cookie.
        This poses a security threat. It is strongly recommended that you
        provide a secret to prevent exploits that may be possible from crafted
        cookies. This will not be supported in future versions of Rack, and
        future versions will even invalidate your existing user cookies.

        Called from: /usr/local/rvm/gems/ruby-1.9.3-p484/gems/actionpack-3.2.8/lib/action_dispatch/middleware/session/abstract_store.rb:28:in `initialize'.

以下是我的 gemfile 代码:

source 'https://rubygems.org'

gem 'rails', '3.2.8'
gem 'rake' , '10.1.0'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'


gem 'json','1.8.0'
gem 'thin' ,'1.5.1'

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  gem 'therubyracer', '0.10.2', :platforms => :ruby
  gem 'less-rails','2.2.6'
  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails', :git => 'https://github.com/rails/jquery-rails.git'

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# To use Jbuilder templates for JSON
# gem 'jbuilder'

# Use unicorn as the app server
# gem 'unicorn'

# Deploy with Capistrano
 gem 'capistrano','2.15.5'
gem 'rvm-capistrano' ,'1.4.3'


# To use debugger
# gem 'ruby-debug'

我在 nginx 上运行 4 个瘦服务器。我尝试了很多东西,但没有任何帮助。

任何帮助将不胜感激。

更新:-

我已将应用程序移至 Amazon EC2 上的 32 位 Ubuntu 服务器,它似乎运行良好。

我似乎不明白这个问题,但必须在几天后将应用程序放回 64 位服务器上。

我没有看到应用程序有任何问题,但不知道为什么它在 64 位服务器上崩溃。是与瘦服务器有关还是与 gems 有任何问题?

请帮我解决这个问题

【问题讨论】:

  • @falsetru 关于这个的任何想法
  • 你如何实际启动服务器?通过哪个命令?另外,您使用哪些工具来部署应用程序?
  • @marvelousNinja 我使用以下命令:-bundle exec thin -p 3000 e -production -s4 start。我目前没有使用任何部署工具
  • 如果你改变环境,问题是否仍然存在?说,电子开发?
  • @marvelousNinja 它在本地环境中运行良好..只有生产出现问题

标签: ruby-on-rails ubuntu nginx amazon-ec2


【解决方案1】:

试试这个

瘦 -e 生产 -d 开始

-e 代表环境 -d 允许它在后台运行 当你不使用 -d 时,它需要一个打开的终端才能继续运行

我在这里找到了答案 http://articles.slicehost.com/2008/5/6/ubuntu-hardy-thin-web-server-for-ruby

【讨论】:

  • 是的,我仍然给我一个错误..同一个..任何其他想法
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-07-12
  • 2012-12-05
  • 2017-09-21
  • 2019-02-04
  • 2022-08-19
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多