-1

我有一个非常简单的 Ruby Serve原型网站,它在本地运行良好,但在 Heroku 上不起作用:

Aug 02 12:35:40 localp app/web.1:  [2013-08-02 11:35:40] INFO  WEBrick 1.3.1 
Aug 02 12:35:40 localp app/web.1:  [2013-08-02 11:35:40] INFO  ruby 1.9.3 (2013-06-27) [x86_64-linux] 
Aug 02 12:35:40 localp app/web.1:  [2013-08-02 11:35:40] INFO  WEBrick::HTTPServer#start: pid=2 port=4000 
Aug 02 12:36:39 localp heroku/web.1:  Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch 
Aug 02 12:36:39 localp heroku/web.1:  Stopping process with SIGKILL 
Aug 02 12:36:41 localp heroku/web.1:  Process exited with status 137 
Aug 02 12:36:41 localp heroku/web.1:  State changed from starting to crashed 

认为这可能与宝石未正确加载有关,因为这是我得到的本地警告:

[2013-08-02 12:39:22] INFO  WEBrick 1.3.1
[2013-08-02 12:39:22] INFO  ruby 1.9.3 (2012-10-12) [x86_64-darwin12.2.0]
[2013-08-02 12:39:22] INFO  WEBrick::HTTPServer#start: pid=79265 port=4000
WARN: serve autoloading 'slim' in a non thread-safe way; explicit require 'slim' suggested.
WARN: serve autoloading 'slim' in a non thread-safe way; explicit require 'slim' suggested.
WARN: serve autoloading 'slim' in a non thread-safe way; explicit require 'slim' suggested.
WARN: serve autoloading 'slim' in a non thread-safe way; explicit require 'slim' suggested.
WARN: tilt autoloading 'redcarpet' in a non thread-safe way; explicit require 'redcarpet' suggested.
WARN: tilt autoloading 'rdiscount' in a non thread-safe way; explicit require 'rdiscount' suggested.
127.0.0.1 - local [02/Aug/2013 12:40:10] "GET /wireframes/ HTTP/1.1" 200 - 0.2049
127.0.0.1 - local [02/Aug/2013 12:40:10] "GET /styles/style.css HTTP/1.1" 200 765 0.0018
127.0.0.1 - local [02/Aug/2013 12:40:10] "GET /favicon.ico HTTP/1.1" 404 31 0.0026

我曾尝试明确要求 gems,但我收到相同的错误消息。这是我的 Gemfile:

source 'https://rubygems.org'
ruby '1.9.3'
gem 'serve', '1.5.2'

gem 'rack-contrib'
gem 'compass'
gem 'sass-globbing'
gem 'rdiscount', :require => 'rdiscount'
gem 'slim', :require => 'slim'

FWIW,这是我的 Procfile:

web: bundle exec rackup config.ru -p $PORT

我已经看遍了 Stack Overflow。有一些答案,但它们与在 Rails 上预编译资产有关。任何想法可能是什么问题?

4

1 回答 1

1

WEBrick is a Ruby webserver designed for development and not recommended for production use. It's also multithreaded.

Try adding gem "thin" to your Gemfile. Heroku will then use Thin as the server, which is not multithreaded (by default though it has a threaded option), and your non thread-safe way will probably go away.

于 2013-08-02T13:30:40.617 回答