문제

I have a very simple Ruby Serve prototype website, which works fine locally but doesn't work on 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 

I think it may have something to do with gems not loading properly, as this is the local warning I get:

[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

I have tried requiring gems explicitly but I get the same error message. Here is my 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, here is my Procfile:

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

I've had a look all over Stack Overflow. There are some answers but they relate to precompiling assets on Rails. Any ideas what the issue could be?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top