1

哪些步骤将重现该问题?

  1. 在 amazon ec2 上用橡胶设置导轨,乘客 4.0.23。
  2. 部署
  3. 检查 apache 日志

什么是预期的输出?我看到了什么?

我希望有一个可用的 Rails 网站。我得到页面无法显示。

Phusion 乘客版本、轨道、操作系统

亚马逊 EC2 上的 Rails 4.0.0 乘客 4.0.23 操作系统 Ubuntu 12.04

下面的附加信息。

我使用橡胶宝石来设置亚马逊 ec2 实例。一切都很好。并且部署成功。但我无法实时看到我的应用程序。我检查了 apache 日志,那里有乘客错误。

[website]       [ 2013-11-12 16:39:57.9413 31599/7f14572a4700 Pool2/Implementation.cpp:1274 ]: [App 31913 stdout] Started GET "/" for 127.0.0.1 at 2013-11-12 16:39:57 -0500
[website]       [ 2013-11-12 16:39:57.9487 31599/7f14572a4700 Pool2/Implementation.cpp:1274 ]: [App 31913 stdout] Processing by HighVoltage::PagesController#show as */*
[website]       [ 2013-11-12 16:39:57.9489 31599/7f14572a4700 Pool2/Implementation.cpp:1274 ]: [App 31913 stdout]   Parameters: {"id"=>"home"}
[website]       [ 2013-11-12 16:39:57.9490 31599/7f14572a4700 Pool2/Implementation.cpp:1274 ]: [App 31913 stdout]   Rendered pages/home.html.slim within layouts/application (1.4ms)
[website]       [ 2013-11-12 16:39:57.9491 31599/7f14572a4700 Pool2/Implementation.cpp:1274 ]: [App 31913 stdout]   Rendered layouts/_header.html.slim (1.0ms)
[website]       [ 2013-11-12 16:39:57.9492 31599/7f14572a4700 Pool2/Implementation.cpp:1274 ]: [App 31913 stdout]   Rendered layouts/_mob_os_icons.html.slim (0.0ms)
[website]       [ 2013-11-12 16:39:57.9493 31599/7f14572a4700 Pool2/Implementation.cpp:1274 ]: [App 31913 stdout]   Rendered layouts/_social_icons.html.slim (0.0ms)
[website]       [ 2013-11-12 16:39:57.9494 31599/7f14572a4700 Pool2/Implementation.cpp:1274 ]: [App 31913 stdout]   Rendered layouts/_footer.html.slim (0.5ms)
[website]       [ 2013-11-12 16:39:57.9520 31599/7f14572a4700 Pool2/Implementation.cpp:1274 ]: [App 31913 stdout]   Rendered layouts/_support_form.html.slim (3.8ms)
[website]       [ 2013-11-12 16:39:57.9524 31599/7f14572a4700 Pool2/Implementation.cpp:1274 ]: [App 31913 stdout] Completed 200 OK in 9ms (Views: 8.4ms | ActiveRecord: 0.0ms)
[website]       [ 2013-11-12 16:39:58.0194 31599/7f145e841700 Pool2/Spawner.h:796 ]: [App 2343 stdout] 
[website]       [ 2013-11-12 16:40:06.8283 31599/7f145e841700 Pool2/SmartSpawner.h:305 ]: Preloader for /mnt/aniways_website-production/releases/20131112204117 started on PID 2343, listening on unix:/tmp/passenger.1.0.31592/generation-0/backends/preloader.2343
[website]       [ 2013-11-12 16:40:07.1492 31599/7f145e841700 Pool2/SmartSpawner.h:693 ]: An error occurred while spawning a process: An error occurred while starting the web application. It exited before signalling successful startup back to Phusion Passenger.
[website]       [ 2013-11-12 16:40:07.1494 31599/7f145e841700 Pool2/SmartSpawner.h:694 ]: The application preloader seems to have crashed, restarting it and trying again...
[website]       [ 2013-11-12 16:40:07.1727 31599/7f145e882700 Pool2/Implementation.cpp:1274 ]: [App 2343 stderr] /usr/local/rubies/2.0.0-p0/lib/ruby/gems/2.0.0/gems/passenger-4.0.23/lib/phusion_passenger/preloader_shared_helpers.rb:66:in `fork': Cannot allocate memory - fork(2) (Errno::ENOMEM)
[website]       [ 2013-11-12 16:40:07.1729 31599/7f145e882700 Pool2/Implementation.cpp:1274 ]: [App 2343 stderr]    from /usr/local/rubies/2.0.0-p0/lib/ruby/gems/2.0.0/gems/passenger-4.0.23/lib/phusion_passenger/preloader_shared_helpers.rb:66:in `accept_and_process_next_client'
[website]       [ 2013-11-12 16:40:07.1730 31599/7f145e882700 Pool2/Implementation.cpp:1274 ]: [App 2343 stderr]    from /usr/local/rubies/2.0.0-p0/lib/ruby/gems/2.0.0/gems/passenger-4.0.23/lib/phusion_passenger/preloader_shared_helpers.rb:116:in `run_main_loop'
[website]       [ 2013-11-12 16:40:07.1810 31599/7f145e882700 Pool2/Implementation.cpp:1274 ]: [App 2343 stderr]    from /usr/local/rubies/2.0.0-p0/lib/ruby/gems/2.0.0/gems/passenger-4.0.23/helper-scripts/rack-preloader.rb:151:in `<module:App>'
[website]       [ 2013-11-12 16:40:07.1811 31599/7f145e882700 Pool2/Implementation.cpp:1274 ]: [App 2343 stderr]    from /usr/local/rubies/2.0.0-p0/lib/ruby/gems/2.0.0/gems/passenger-4.0.23/helper-scripts/rack-preloader.rb:29:in `<module:PhusionPassenger>'
[website]       [ 2013-11-12 16:40:07.1812 31599/7f145e882700 Pool2/Implementation.cpp:1274 ]: [App 2343 stderr]    from /usr/local/rubies/2.0.0-p0/lib/ruby/gems/2.0.0/gems/passenger-4.0.23/helper-scripts/rack-preloader.rb:28:in `<main>'
[website]       [ 2013-11-12 16:40:08.7635 31599/7f145e841700 Pool2/Spawner.h:796 ]: [App 2491 stdout] 
[website]       [ 2013-11-12 16:40:13.0087 31599/7f145e841700 Pool2/SmartSpawner.h:305 ]: Preloader for /mnt/aniways_website-production/releases/20131112204117 started on PID 2491, listening on unix:/tmp/passenger.1.0.31592/generation-0/backends/preloader.2491
[website]       [ 2013-11-12 16:40:13.1094 31599/7f145e78a700 Pool2/Implementation.cpp:1274 ]: [App 2491 stderr] /usr/local/rubies/2.0.0-p0/lib/ruby/gems/2.0.0/gems/passenger-4.0.23/lib/phusion_passenger/preloader_shared_helpers.rb:66:in `fork'
[website]       [ 2013-11-12 16:40:13.1111 31599/7f145e78a700 Pool2/Implementation.cpp:1274 ]: [App 2491 stderr] : Cannot allocate memory - fork(2) (Errno::ENOMEM)
[website]       [ 2013-11-12 16:40:13.1113 31599/7f145e78a700 Pool2/Implementation.cpp:1274 ]: [App 2491 stderr]    from /usr/local/rubies/2.0.0-p0/lib/ruby/gems/2.0.0/gems/passenger-4.0.23/lib/phusion_passenger/preloader_shared_helpers.rb:66:in `accept_and_process_next_client'
[website]       [ 2013-11-12 16:40:13.1114 31599/7f145e78a700 Pool2/Implementation.cpp:1274 ]: [App 2491 stderr]    from /usr/local/rubies/2.0.0-p0/lib/ruby/gems/2.0.0/gems/passenger-4.0.23/lib/phusion_passenger/preloader_shared_helpers.rb:116:in `run_main_loop'
[website]       [ 2013-11-12 16:40:13.1115 31599/7f145e78a700 Pool2/Implementation.cpp:1274 ]: [App 2491 stderr]    from /usr/local/rubies/2.0.0-p0/lib/ruby/gems/2.0.0/gems/passenger-4.0.23/helper-scripts/rack-preloader.rb:151:in `<module:App>'
[website]       [ 2013-11-12 16:40:13.1117 31599/7f145e78a700 Pool2/Implementation.cpp:1274 ]: [App 2491 stderr]    from /usr/local/rubies/2.0.0-p0/lib/ruby/gems/2.0.0/gems/passenger-4.0.23/helper-scripts/rack-preloader.rb:29:in `<module:PhusionPassenger>'
[website]       [ 2013-11-12 16:40:13.1118 31599/7f145e78a700 Pool2/Implementation.cpp:1274 ]: [App 2491 stderr]    from /usr/local/rubies/2.0.0-p0/lib/ruby/gems/2.0.0/gems/passenger-4.0.23/helper-scripts/rack-preloader.rb:28:in `<main>'
[website]       [ 2013-11-12 16:40:13.2386 31599/7f145e841700 Pool2/Implementation.cpp:849 ]: Could not spawn process for group /mnt/aniways_website-production/releases/20131112204117#default: An error occurred while starting the web application. It exited before signalling successful startup back to Phusion Passenger.
[website]            in 'void Passenger::ApplicationPool2::Spawner::throwAppSpawnException(const string&, Passenger::SpawnException::ErrorKind, Passenger::ApplicationPool2::Spawner::NegotiationDetails&)' (Spawner.h:689)
[website]            in 'Passenger::ApplicationPool2::SmartSpawner::SpawnResult Passenger::ApplicationPool2::SmartSpawner::sendSpawnCommand(const Passenger::ApplicationPool2::Options&)' (SmartSpawner.h:682)
[website]            in 'Passenger::ApplicationPool2::SmartSpawner::SpawnResult Passenger::ApplicationPool2::SmartSpawner::sendSpawnCommandAgain(const Exception&, const Passenger::ApplicationPool2::Options&) [with Exception = Passenger::SpawnException]' (SmartSpawner.h:692)
[website]            in 'virtual Passenger::ApplicationPool2::ProcessPtr Passenger::ApplicationPool2::SmartSpawner::spawn(const Passenger::ApplicationPool2::Options&)' (SmartSpawner.h:760)
[website]            in 'void Passenger::ApplicationPool2::Group::spawnThreadRealMain(const SpawnerPtr&, const Passenger::ApplicationPool2::Options&, unsigned int)' (Implementation.cpp:782)
[website] 

更新

按照 Hongli 的建议,我将 MaxPoolSize 减少到 5。

现在,我在错误日志中得到了这个。

[ 2013-11-13 14:12:07.5599 5103/7fa04475e740 agents/HelperAgent/Main.cpp:619 ]: PassengerHelperAgent online, listening at unix:/tmp/passenger.1.0.5096/generation-0/request
[ 2013-11-13 14:12:07.5780 5108/7f4e3dddd740 agents/LoggingAgent/Main.cpp:318 ]: PassengerLoggingAgent online, listening at unix:/tmp/passenger.1.0.5096/generation-0/logging
[ 2013-11-13 14:12:07.5820 5100/7f470d55d740 agents/Watchdog/Main.cpp:761 ]: All Phusion Passenger agents started!
[Wed Nov 13 14:12:07 2013] [notice] Apache/2.2.22 (Ubuntu) proxy_html/3.0.1 mod_ssl/2.2.22 OpenSSL/1.0.1 Phusion_Passenger/4.0.23 configured -- resuming normal operations
[ 2013-11-13 14:12:11.0335 5103/7fa044687700 Pool2/Spawner.h:796 ]: [App 5252 stdout] 
[ 2013-11-13 14:12:14.0589 5103/7fa044687700 Pool2/SmartSpawner.h:305 ]: Preloader for /mnt/jashwant_website-production/releases/20131113190730 started on PID 5252, listening on unix:/tmp/passenger.1.0.5096/generation-0/backends/preloader.5252
[ 2013-11-13 14:12:14.3681 5103/7fa0445d0700 Pool2/Implementation.cpp:1274 ]: [App 5277 stdout] Started GET "/" for 127.0.0.1 at 2013-11-13 14:12:14 -0500
[ 2013-11-13 14:12:14.4019 5103/7fa0445d0700 Pool2/Implementation.cpp:1274 ]: [App 5277 stdout] Processing by HighVoltage::PagesController#show as */*
[ 2013-11-13 14:12:14.4101 5103/7fa0445d0700 Pool2/Implementation.cpp:1274 ]: [App 5277 stdout]   Parameters: {"id"=>"home"}
[ 2013-11-13 14:12:14.5424 5103/7fa0445d0700 Pool2/Implementation.cpp:1274 ]: [App 5277 stdout]   Rendered pages/home.html.slim within layouts/application (59.9ms)
[ 2013-11-13 14:12:14.5987 5103/7fa0445d0700 Pool2/Implementation.cpp:1274 ]: [App 5277 stdout]   Rendered layouts/_header.html.slim (23.9ms)
[ 2013-11-13 14:12:14.7445 5103/7fa0445d0700 Pool2/Implementation.cpp:1274 ]: [App 5277 stdout]   Rendered layouts/_mob_os_icons.html.slim (7.4ms)
[ 2013-11-13 14:12:14.7631 5103/7fa0445d0700 Pool2/Implementation.cpp:1274 ]: [App 5277 stdout]   Rendered layouts/_social_icons.html.slim (7.2ms)
[ 2013-11-13 14:12:14.7633 5103/7fa0445d0700 Pool2/Implementation.cpp:1274 ]: [App 5277 stdout]   Rendered layouts/_footer.html.slim (155.8ms)
[ 2013-11-13 14:12:14.8396 5103/7fa0445d0700 Pool2/Implementation.cpp:1274 ]: [App 5277 stdout]   Rendered layouts/_support_form.html.slim (71.4ms)
[ 2013-11-13 14:12:14.8413 5103/7fa0445d0700 Pool2/Implementation.cpp:1274 ]: [App 5277 stdout] Completed 200 OK in 431ms (Views: 377.7ms | ActiveRecord: 0.0ms)

我认为这意味着服务器设置成功。但我仍然无法在线浏览我的网站。(我已经检查了安全组,它们允许 0.0.0.0 到端口 80/443。mysql 也是如此。Rails/log/production.log是空的。

更新 2 我在 haproxy 日志中看到了这个

Nov 13 15:02:23 localhost haproxy[5580]: Server passenger_proxy/website is DOWN, reason: Layer7 wrong status, code: 404, info: "Not Found", check duration: 5ms. 0 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
4

2 回答 2

2

Phusion 乘客作者在这里。

在日志中注意到这一点了吗?

 Cannot allocate memory - fork(2) (Errno::ENOMEM)

这意味着您的系统内存不足

并注意到这一点?

 An error occurred while starting the web application.
 It exited before signalling successful startup back to Phusion Passenger.

这意味着Passenger 尝试为您的Web 应用程序生成一个进程,但由于上述错误(内存不足)而失败。

您可以做 3 件事:

  • 升级你的记忆。
  • 升级您的交换空间。
  • 调整您的乘客设置,使其不会启动那么多进程。这可以节省您的内存。查看乘客手册以了解调整选项。
于 2013-11-13T13:14:31.770 回答
0

我会建议你使用Passenger+Nginx Modul。以下是安装 Ruby、rails 和配置乘客的步骤。

  1. 安装所需的库

    sudo apt-get install zlib1g zlib1g-dev build-essential openssl libssl-dev libmysqlclient18 libmysqlclient-dev libyaml-dev curl git-core python-software-properties libpq-dev nodejs
    
  2. 下载并安装 Ruby 1.9.3

    sudo apt-get update
    sudo apt-get install ruby1.9.3
    

    或者

    wget ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p195.tar.gz
    apt-get install wget build-eruby+rails+mysql+passenger+ngnixssential make     
    cd ruby-2.0.0
    $  ./configure
    $   make
    $   sudo make install
    

3.下载 RUBY GEM:标准的 RUBY PACKAGE MANAGER 不需要安装,在安装 ruby​​ 的时候就已经安装好了

4.安装导轨

sudo apt-get install ruby-dev
sudo gem install rails

8.乘客安装

gem install passenger 

9.安装NGINX

sudo apt-get install libcurl4-openssl-dev or libcurl4-gnutls-dev
sudo apt-get install libssl-dev
sudo passenger-install-nginx-module

10.启动NGINX

    sudo service nginx start
于 2013-11-13T12:54:26.503 回答