【问题标题】:Problems with Rails 4 app into BluehostRails 4 应用程序进入 Bluehost 的问题
【发布时间】:2015-03-05 17:34:24
【问题描述】:

我在启动我在 bluehost 上托管的 rails 应用时遇到了一些问题。

我认为问题在于乘客版本与 rails 4 应用程序交互,但我不确定。

当我启动我的应用程序时,我得到了这个跟踪:

Ruby (Rack) application could not be started
These are the possible causes:
There may be a syntax error in the application's code. Please check for such errors and fix them.
A required library may not installed. Please install all libraries that this application requires.
The application may not be properly configured. Please check whether all configuration files are written correctly, fix any incorrect configurations, and restart this application.
A service that the application relies on (such as the database server or the Ferret search engine server) may not have been started. Please start that service.
Further information about the error may have been written to the application's log file. Please check it in order to analyse the problem.
Error message:
Could not initialize MySQL client library
Exception class:
RuntimeError
Application root:
/home5/barracam/rails_apps/admin/admin
Backtrace:
#   File    Line    Location
0   /home5/barracam/ruby/gems/gems/mysql2-0.3.18/lib/mysql2.rb  31  in `require'
1   /home5/barracam/ruby/gems/gems/mysql2-0.3.18/lib/mysql2.rb  31  in `'
2   /usr/lib64/ruby/gems/1.9.3/gems/bundler-1.3.5/lib/bundler/runtime.rb    72  in `require'
3   /usr/lib64/ruby/gems/1.9.3/gems/bundler-1.3.5/lib/bundler/runtime.rb    72  in `block (2 levels) in require'
4   /usr/lib64/ruby/gems/1.9.3/gems/bundler-1.3.5/lib/bundler/runtime.rb    70  in `each'
5   /usr/lib64/ruby/gems/1.9.3/gems/bundler-1.3.5/lib/bundler/runtime.rb    70  in `block in require'
6   /usr/lib64/ruby/gems/1.9.3/gems/bundler-1.3.5/lib/bundler/runtime.rb    59  in `each'
7   /usr/lib64/ruby/gems/1.9.3/gems/bundler-1.3.5/lib/bundler/runtime.rb    59  in `require'
8   /usr/lib64/ruby/gems/1.9.3/gems/bundler-1.3.5/lib/bundler.rb    132 in `require'
9   /home5/barracam/rails_apps/admin/admin/config/application.rb    7   in `'
10  /home5/barracam/rails_apps/admin/admin/config/environment.rb    2   in `require'
11  /home5/barracam/rails_apps/admin/admin/config/environment.rb    2   in `'
12  config.ru   3   in `require'
13  config.ru   3   in `block in'
14  /home5/barracam/ruby/gems/gems/rack-1.5.2/lib/rack/builder.rb   55  in `instance_eval'
15  /home5/barracam/ruby/gems/gems/rack-1.5.2/lib/rack/builder.rb   55  in `initialize'
16  config.ru   1   in `new'
17  config.ru   1   in `'
18  /etc/httpd/modules/passenger/lib/phusion_passenger/rack/application_spawner.rb  225 in `eval'
19  /etc/httpd/modules/passenger/lib/phusion_passenger/rack/application_spawner.rb  225 in `load_rack_app'
20  /etc/httpd/modules/passenger/lib/phusion_passenger/rack/application_spawner.rb  157 in `block in initialize_server'
21  /etc/httpd/modules/passenger/lib/phusion_passenger/utils.rb 563 in `report_app_init_status'
22  /etc/httpd/modules/passenger/lib/phusion_passenger/rack/application_spawner.rb  154 in `initialize_server'
23  /etc/httpd/modules/passenger/lib/phusion_passenger/abstract_server.rb   204 in `start_synchronously'
24  /etc/httpd/modules/passenger/lib/phusion_passenger/abstract_server.rb   180 in `start'
25  /etc/httpd/modules/passenger/lib/phusion_passenger/rack/application_spawner.rb  129 in `start'
26  /etc/httpd/modules/passenger/lib/phusion_passenger/spawn_manager.rb 253 in `block (2 levels) in spawn_rack_application'
27  /etc/httpd/modules/passenger/lib/phusion_passenger/abstract_server_collection.rb    132 in `lookup_or_add'
28  /etc/httpd/modules/passenger/lib/phusion_passenger/spawn_manager.rb 246 in `block in spawn_rack_application'
29  /etc/httpd/modules/passenger/lib/phusion_passenger/abstract_server_collection.rb    82  in `block in synchronize'
30      prelude>    10:in `synchronize'
31  /etc/httpd/modules/passenger/lib/phusion_passenger/abstract_server_collection.rb    79  in `synchronize'
32  /etc/httpd/modules/passenger/lib/phusion_passenger/spawn_manager.rb 244 in `spawn_rack_application'
33  /etc/httpd/modules/passenger/lib/phusion_passenger/spawn_manager.rb 137 in `spawn_application'
34  /etc/httpd/modules/passenger/lib/phusion_passenger/spawn_manager.rb 275 in `handle_spawn_application'
35  /etc/httpd/modules/passenger/lib/phusion_passenger/abstract_server.rb   357 in `server_main_loop'
36  /etc/httpd/modules/passenger/lib/phusion_passenger/abstract_server.rb   206 in `start_synchronously'
37  /etc/httpd/modules/passenger/helper-scripts/passenger-spawn-server  99  in `'
Powered by Phusion Passenger, mod_rails / mod_rack for Apache and Nginx.

我尝试运行 rails 3 应用程序,一切正常。你怎么看这个问题?

非常感谢任何帮助。

【问题讨论】:

  • 不是一个答案,而是一个问题:有什么理由不使用 Heroku 或其他对应用程序友好的部署? Bluehost,我发现在尝试将应用程序部署到那里时真的会消耗大量时间。
  • 有些不是功能要求。这个想法是将所有内容都放入客户端bluehost服务器中。但也许你是对的,指向 Heroku 应用的域似乎是解决这个问题的最佳方案。
  • 这正是我最终所做的。
  • 还有一件事。我了解在一台主机上完成所有工作的目标,我正在寻找 Webfaction 托管以将我的所有工作迁移到。他们声称对应用程序友好,但价格合理。

标签: mysql ruby-on-rails ruby-on-rails-4 passenger


【解决方案1】:

我遇到了同样的错误,所以经过大量研究和反复试验......我将我的 mysql2 gem 锁定在 3.0.16 版本,并像这样设置我的 database.yml:

adapter: mysql2
encoding: utf8
database: store
username: root
password: 
host: localhost
reconnect: true
port: 3306

我的应用在 4.20 上运行 rails,现在运行良好。 (尽管连接到 mysql 数据库时仍然偶尔出现问题?也许最蓝的服务器超载了?没有真正的模式,也不会经常发生。

【讨论】:

  • 我会试一试,但要知道我的应用程序正在使用 postgreSQL 数据库运行,没有问题。
  • @halbano 我最终也迁移到了 postgresql。 mysql 是 bluehost 上的噩梦。服务器每隔 10 分钟左右就会关闭一次……我不再使用 postgresql 出现这样的问题了。
【解决方案2】:

尝试更改database.yml

使用mysql 代替mysql2 适配器

【讨论】:

    猜你喜欢
    • 2016-07-05
    • 2012-03-24
    • 2015-03-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多