ruby-on-rails - Apache2 Passenger(谷歌计算引擎)通过 Ruby 版本捕获 SIGTERM?

标签 ruby-on-rails ruby apache passenger google-compute-engine

出于某种原因,Apache 似乎不喜欢我的 Rails 应用程序,该应用程序在 Google Compute Engine 上与 Phusion Passenger 一起运行(目前使用 WEBrick)。我在 Google 的“Click-to-Deploy”ruby 实例上运行它,该实例在 Debian 上运行。我还将 Ruby 更新到 2.2.2 并设置 rvm use global 2.2.2 .

我去rails s启动服务器,转到IP地址,然后得到一个可爱的500 Internal Error Apache 说我的服务器配置很困惑。如果我尝试去 <ip_address>:3000我没有收到服务器的响应。

配置文件(位于/etc/apache2/sites-available/

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /home/nick/qwestera
        RailsEnv production
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory "/home/nick/qwestera">
                Options FollowSymLinks
                Require all granted
        </Directory>
        ErrorLog ${APACHE_LOG_DIR}/error.log
        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

日志(错误重复):

[ 2015-07-31 18:46:36.9094 8146/7f0809eaa720 agents/Watchdog/Main.cpp:728 ]: All Phusion Passenger agents started!
[Fri Jul 31 18:46:36 2015] [notice] Apache/2.2.22 (Debian) Phusion_Passenger/4.0.58 configured -- resuming normal operations
[Fri Jul 31 18:46:48 2015] [crit] [client 98.117.13.138] configuration error:  couldn't perform authentication. AuthType not set!: /
[Fri Jul 31 18:46:49 2015] [crit] [client 98.117.13.138] configuration error:  couldn't perform authentication. AuthType not set!: /favicon.ico, referer: http://130.211.115.98/
[Fri Jul 31 18:46:58 2015] [crit] [client 98.117.13.138] configuration error:  couldn't perform authentication. AuthType not set!: /
[Fri Jul 31 18:46:59 2015] [crit] [client 98.117.13.138] configuration error:  couldn't perform authentication. AuthType not set!: /favicon.ico, referer: http://130.211.115.98/
[Fri Jul 31 18:47:02 2015] [crit] [client 98.117.13.138] configuration error:  couldn't perform authentication. AuthType not set!: /
[Fri Jul 31 18:47:02 2015] [crit] [client 98.117.13.138] configuration error:  couldn't perform authentication. AuthType not set!: /favicon.ico, referer: http://130.211.115.98/
[Fri Jul 31 18:47:17 2015] [crit] [client 98.117.13.138] configuration error:  couldn't perform authentication. AuthType not set!: /
[Fri Jul 31 18:47:17 2015] [crit] [client 98.117.13.138] configuration error:  couldn't perform authentication. AuthType not set!: /favicon.ico, referer: http://130.211.115.98/
[Fri Jul 31 18:47:17 2015] [crit] [client 98.117.13.138] configuration error:  couldn't perform authentication. AuthType not set!: /favicon.ico, referer: http://130.211.115.98/
[Fri Jul 31 18:47:19 2015] [crit] [client 98.117.13.138] configuration error:  couldn't perform authentication. AuthType not set!: /
[Fri Jul 31 18:47:19 2015] [crit] [client 98.117.13.138] configuration error:  couldn't perform authentication. AuthType not set!: /favicon.ico, referer: http://130.211.115.98/
[Fri Jul 31 18:48:08 2015] [crit] [client 98.117.13.138] configuration error:  couldn't perform authentication. AuthType not set!: /
[Fri Jul 31 18:48:08 2015] [crit] [client 98.117.13.138] configuration error:  couldn't perform authentication. AuthType not set!: /favicon.ico, referer: http://130.211.115.98/
[Fri Jul 31 18:55:23 2015] [notice] caught SIGTERM, shutting down
[ 2015-07-31 18:55:24.5305 3807/7f317e333720 agents/Watchdog/Main.cpp:538 ]: Options: { 'analytics_log_user' => 'nobody', 'default_group' => 'nogroup', 'default_python' => 'python', 'default_ruby' => '/usr/local/rvm/gems/ruby-2.1.1/wrappers/ruby', 'default_user' => 'nobody', 'log_level' => '0', 'max_pool_size' => '6', 'passenger_root' => '/usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.58', 'passenger_version' => '4.0.58', 'pool_idle_time' => '300', 'temp_dir' => '/tmp', 'union_station_gateway_address' => 'gateway.unionstationapp.com', 'union_station_gateway_port' => '443', 'user_switching' => 'true', 'web_server_passenger_version' => '4.0.58', 'web_server_pid' => '5755', 'web_server_type' => 'apache', 'web_server_worker_gid' => '33', 'web_server_worker_uid' => '33' }
[ 2015-07-31 18:55:24.5352 3810/7fb4d8c13720 agents/HelperAgent/Main.cpp:650 ]: PassengerHelperAgent online, listening at unix:/tmp/passenger.1.0.3806/generation-0/request
[ 2015-07-31 18:55:24.5413 3816/7f854bdf8740 agents/LoggingAgent/Main.cpp:321 ]: PassengerLoggingAgent online, listening at unix:/tmp/passenger.1.0.3806/generation-0/logging
[ 2015-07-31 18:55:24.5416 3807/7f317e333720 agents/Watchdog/Main.cpp:728 ]: All Phusion Passenger agents started!
[ 2015-07-31 18:55:24.5609 3832/7f94e6c6b720 agents/Watchdog/Main.cpp:538 ]: Options: { 'analytics_log_user' => 'nobody', 'default_group' => 'nogroup', 'default_python' => 'python', 'default_ruby' => '$
[ 2015-07-31 18:55:24.5669 3840/7f6a6a654720 agents/HelperAgent/Main.cpp:650 ]: PassengerHelperAgent online, listening at unix:/tmp/passenger.1.0.3827/generation-0/request
[ 2015-07-31 18:55:24.5730 3853/7f5623e51740 agents/LoggingAgent/Main.cpp:321 ]: PassengerLoggingAgent online, listening at unix:/tmp/passenger.1.0.3827/generation-0/logging
[ 2015-07-31 18:55:24.5733 3832/7f94e6c6b720 agents/Watchdog/Main.cpp:728 ]: All Phusion Passenger agents started!
[Fri Jul 31 18:55:24 2015] [notice] Apache/2.2.22 (Debian) Phusion_Passenger/4.0.58 configured -- resuming normal operations
[Fri Jul 31 18:55:54 2015] [crit] [client 98.117.13.138] configuration error:  couldn't perform authentication. AuthType not set!: /
[Fri Jul 31 18:55:54 2015] [crit] [client 98.117.13.138] configuration error:  couldn't perform authentication. AuthType not set!: /favicon.ico, referer: http://130.211.115.98/
[Fri Jul 31 18:55:59 2015] [crit] [client 98.117.13.138] configuration error:  couldn't perform authentication. AuthType not set!: /
[Fri Jul 31 18:55:59 2015] [crit] [client 98.117.13.138] configuration error:  couldn't perform authentication. AuthType not set!: /favicon.ico, referer: http://130.211.115.98/
[Fri Jul 31 18:56:01 2015] [crit] [client 98.117.13.138] configuration error:  couldn't perform authentication. AuthType not set!: /
[Fri Jul 31 18:56:01 2015] [crit] [client 98.117.13.138] configuration error:  couldn't perform authentication. AuthType not set!: /favicon.ico, referer: http://130.211.115.98/
[Fri Jul 31 18:56:46 2015] [crit] [client 98.117.13.138] configuration error:  couldn't perform authentication. AuthType not set!: /
[Fri Jul 31 18:56:46 2015] [crit] [client 98.117.13.138] configuration error:  couldn't perform authentication. AuthType not set!: /favicon.ico, referer: http://130.211.115.98/
[Fri Jul 31 18:56:49 2015] [crit] [client 98.117.13.138] configuration error:  couldn't perform authentication. AuthType not set!: /
[Fri Jul 31 18:56:49 2015] [crit] [client 98.117.13.138] configuration error:  couldn't perform authentication. AuthType not set!: /favicon.ico, referer: http://130.211.115.98/
[Fri Jul 31 18:58:37 2015] [notice] caught SIGTERM, shutting down
[ 2015-07-31 18:58:38.3388 4200/7f8f1041b720 agents/Watchdog/Main.cpp:538 ]: Options: { 'analytics_log_user' => 'nobody', 'default_group' => 'nogroup', 'default_python' => 'python', 'default_ruby' => '$
[ 2015-07-31 18:58:38.3434 4203/7fe96b315720 agents/HelperAgent/Main.cpp:650 ]: PassengerHelperAgent online, listening at unix:/tmp/passenger.1.0.4199/generation-0/request
[ 2015-07-31 18:58:38.3489 4209/7fe051b12740 agents/LoggingAgent/Main.cpp:321 ]: PassengerLoggingAgent online, listening at unix:/tmp/passenger.1.0.4199/generation-0/logging
[ 2015-07-31 18:58:38.3491 4200/7f8f1041b720 agents/Watchdog/Main.cpp:728 ]: All Phusion Passenger agents started!
[ 2015-07-31 18:58:38.3672 4225/7fcc75d26720 agents/Watchdog/Main.cpp:538 ]: Options: { 'analytics_log_user' => 'nobody', 'default_group' => 'nogroup', 'default_python' => 'python', 'default_ruby' => '$
[ 2015-07-31 18:58:38.3725 4233/7f79a2e4c720 agents/HelperAgent/Main.cpp:650 ]: PassengerHelperAgent online, listening at unix:/tmp/passenger.1.0.4220/generation-0/request
[ 2015-07-31 18:58:38.3790 4244/7f0bef1b9740 agents/LoggingAgent/Main.cpp:321 ]: PassengerLoggingAgent online, listening at unix:/tmp/passenger.1.0.4220/generation-0/logging
[ 2015-07-31 18:58:38.3792 4225/7fcc75d26720 agents/Watchdog/Main.cpp:728 ]: All Phusion Passenger agents started!
[Fri Jul 31 18:58:38 2015] [notice] Apache/2.2.22 (Debian) Phusion_Passenger/4.0.58 configured -- resuming normal operations
[Fri Jul 31 18:58:50 2015] [crit] [client 98.117.13.138] configuration error:  couldn't perform authentication. AuthType not set!: /
[Fri Jul 31 18:58:50 2015] [crit] [client 98.117.13.138] configuration error:  couldn't perform authentication. AuthType not set!: /favicon.ico, referer: http://130.211.115.98/
[Fri Jul 31 18:58:53 2015] [crit] [client 98.117.13.138] configuration error:  couldn't perform authentication. AuthType not set!: /
[Fri Jul 31 18:58:53 2015] [crit] [client 98.117.13.138] configuration error:  couldn't perform authentication. AuthType not set!: /favicon.ico, referer: http://130.211.115.98/

认为的日志条目可能会给我一些见解:

[Fri Jul 31 18:55:23 2015] [notice] caught SIGTERM, shutting down
    [ 2015-07-31 18:55:24.5305 3807/7f317e333720 agents/Watchdog/Main.cpp:538 ]: Options: { 'analytics_log_user' => 'nobody', 'default_group' => 'nogroup', 'default_python' => 'python', 'default_ruby' => '/usr/local/rvm/gems/ruby-2.1.1/wrappers/ruby', 'default_user' => 'nobody', 'log_level' => '0', 'max_pool_size' => '6', 'passenger_root' => '/usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.58', 'passenger_version' => '4.0.58', 'pool_idle_time' => '300', 'temp_dir' => '/tmp', 'union_station_gateway_address' => 'gateway.unionstationapp.com', 'union_station_gateway_port' => '443', 'user_switching' => 'true', 'web_server_passenger_version' => '4.0.58', 'web_server_pid' => '5755', 'web_server_type' => 'apache', 'web_server_worker_gid' => '33', 'web_server_worker_uid' => '33' }

具体:

'default_ruby' => '/usr/local/rvm/gems/ruby-2.1.1/wrappers/ruby',

'passenger_root' => '/usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.58'

如果你注意到了,我说过我将 ruby​​ 更新为 2.2.2因为这就是我尝试运行的项目所使用的。然而,Apache 有 default_rubypassenger_root目录包括ruby 2.1.1 。这会是问题吗?如果是这样,我该如何更改?

UPDATE:

正在删除Require all granted让我更近了一步(这一行仅对于大于 2.4 的 Apache 版本是必要的,我的是 2.2)。

现在我得到了一个乘客页面(我的 Rails 应用程序的 favicon.ico 出现了,耶!),让我知道 Web application could not be started .

它向我显示了以下错误:

Your Ruby version is 2.1.1, but your Gemfile specified 2.2.2 (Bundler::RubyVersionMismatch)
  /usr/local/rvm/gems/ruby-2.1.1@global/gems/bundler-1.5.3/lib/bundler/definition.rb:390:in `validate_ruby!'
  /usr/local/rvm/gems/ruby-2.1.1@global/gems/bundler-1.5.3/lib/bundler.rb:115:in `setup'
  /usr/local/rvm/gems/ruby-2.1.1@global/gems/bundler-1.5.3/lib/bundler/setup.rb:17:in `<top (required)>'
  /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:135:in `require'
  /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
  /usr/local/rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:144:in `require'
  /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.58/lib/phusion_passenger/loader_shared_helpers.rb:263:in `block in run_load_path_setup_code'
  /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.58/lib/phusion_passenger/loader_shared_helpers.rb:366:in `running_bundler'
  /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.58/lib/phusion_passenger/loader_shared_helpers.rb:261:in `run_load_path_setup_code'
  /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.58/helper-scripts/rack-preloader.rb:100:in `preload_app'
  /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.58/helper-scripts/rack-preloader.rb:158:in `<module:App>'
  /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.58/helper-scripts/rack-preloader.rb:29:in `<module:PhusionPassenger>'
  /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.58/helper-scripts/rack-preloader.rb:28:in `<main>'

分割: 我完全认为这是 Ruby 版本问题!现在,我如何让乘客知道在 2.2.2 的新 Ruby 目录中查找内容?

有趣且可能富有洞察力:

$ ruby --version
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
$ ruby -version
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
-e:1:in `<main>': undefined local variable or method `rsion' for main:Object (NameError)

ruby -version返回 NameError ,但是ruby --version才不是。搞什么?

UPDATE 2:

嗯,我已经更新了/etc/apache2/apache2.conf 以指向新目录。但是,我的 Rails 应用程序实际上并未运行。我只看到应用程序中所有文件和文件夹的索引。我如何告诉它开始?

最佳答案

通过使用rvm uninstall 2.1.1卸载旧版本的Ruby,使用rvm install 2.2.2重新安装新版本,然后使用passenger再次安装passenger来解决-安装-apache2-module

关于ruby-on-rails - Apache2 Passenger(谷歌计算引擎)通过 Ruby 版本捕获 SIGTERM?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31753549/

相关文章:

ruby-on-rails - 讨论 bluepill 使用 rbenv

ruby-on-rails - 设计 - 如何显示用户的帖子

ruby-on-rails - 在 Rails 中为命名空间路由添加别名

php - WampServer v2.5 上线403错误禁止访问

ruby-on-rails - 解决 PG::GroupingError: ERROR

mysql - Rails 4 - Mysql2::错误:索引列大小太大

ruby - 如何在 ruby​​ 中将服务对象/模块作为参数传递

ruby : Generate a Hash of Hashes from an Array of Hashes

javascript - CORS 响应 header 如何阻止浏览器 JavaScript 访问响应对象?

python - Apache 子进程在分配一个巨大的 block 后不释放内存