我在hi.rb中有这个
require 'rubygems'
require 'sinatra'
get '/hi' do
"Hello World!"
end
如果我执行ruby hi.rb
然后转到我的网络浏览器中的地址,我会看到一个显示“Hello World”的网页。
然后我把它推到Heroku,但它没有显示出来。为什么呢?
这是heroku日志的输出。
2012-03-27T06:13:48+00:00 app[web.1]: from /home/heroku_rack/heroku.ru:1:in `<main>'
2012-03-27T06:13:48+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/controllers/controller.rb:175:in `load_rackup_config'
2012-03-27T06:13:48+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/rack/adapter/loader.rb:36:in `eval'
2012-03-27T06:13:48+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/rack/adapter/loader.rb:36:in `load'
2012-03-27T06:13:48+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/controllers/controller.rb:65:in `start'
2012-03-27T06:13:48+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/runner.rb:177:in `run_command'
2012-03-27T06:13:48+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/runner.rb:143:in `run!'
2012-03-27T06:13:48+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/bin/thin:6:in `<top (required)>'
2012-03-27T06:13:48+00:00 app[web.1]: from /usr/ruby1.9.2/bin/thin:19:in `load'
2012-03-27T06:13:48+00:00 app[web.1]: from /usr/ruby1.9.2/bin/thin:19:in `<main>'
2012-03-27T06:13:50+00:00 heroku[web.1]: Process exited with status 1
2012-03-27T06:13:50+00:00 heroku[web.1]: State changed from starting to crashed
2012-03-27T06:13:55+00:00 heroku[router]: Error H10 (App crashed) -> GET deep-sword-6479.heroku.com/ dyno= queue= wait= service= status=503 bytes=
2012-03-27T06:13:55+00:00 heroku[nginx]: 71.131.178.68 - - [27/Mar/2012:06:13:55 +0000] "GET / HTTP/1.1" 503 607 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:12.0) Gecko/20100101 Firefox/12.0" deep-sword-6479.heroku.com
2012-03-27T06:13:57+00:00 heroku[nginx]: 71.131.178.68 - - [27/Mar/2012:06:13:57 +0000] "GET / HTTP/1.1" 503 607 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:12.0) Gecko/20100101 Firefox/12.0" deep-sword-6479.heroku.com
2012-03-27T06:13:57+00:00 heroku[router]: Error H10 (App crashed) -> GET deep-sword-6479.heroku.com/ dyno= queue= wait= service= status=503 bytes=
2012-03-26T23:15:13-07:00 heroku[slugc]: Slug compilation started
2012-03-27T06:15:17+00:00 heroku[api]: Release v5 created by afontanilla@ucdavis.edu
2012-03-27T06:15:17+00:00 heroku[api]: Deploy 22af87a by afontanilla@ucdavis.edu
2012-03-27T06:15:17+00:00 heroku[web.1]: State changed from crashed to created
2012-03-27T06:15:17+00:00 heroku[web.1]: State changed from created to starting
2012-03-26T23:15:17-07:00 heroku[slugc]: Slug compilation finished
2012-03-27T06:15:19+00:00 heroku[web.1]: Starting process with command `thin -p 42835 -e production -R /home/heroku_rack/heroku.ru start`
2012-03-27T06:15:19+00:00 app[web.1]: <internal:lib/rubygems/custom_require>:29:in `require': no such file to load -- sinatra (LoadError)
2012-03-27T06:15:19+00:00 app[web.1]: from /app/hello.rb:2:in `<top (required)>'
2012-03-27T06:15:19+00:00 app[web.1]: from <internal:lib/rubygems/custom_require>:29:in `require'
2012-03-27T06:15:19+00:00 app[web.1]: from <internal:lib/rubygems/custom_require>:29:in `require'
2012-03-27T06
:15:19+00:00 app[web.1]: from <internal:lib/rubygems/custom_require>:29:in `require'
2012-03-27T06:15:19+00:00 app[web.1]: from /home/heroku_rack/heroku.ru:23:in `eval'
2012-03-27T06:15:19+00:00 app[web.1]: from config.ru:1:in `block (3 levels) in <main>'
2012-03-27T06:15:19+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/builder.rb:46:in `instance_eval'
2012-03-27T06:15:19+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/builder.rb:46:in `initialize'
2012-03-27T06:15:19+00:00 app[web.1]: from /home/heroku_rack/heroku.ru:23:in `block (3 levels) in <main>'
2012-03-27T06:15:19+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/builder.rb:63:in `map'
2012-03-27T06:15:19+00:00 app[web.1]: from /home/heroku_rack/heroku.ru:18:in `block (2 levels) in <main>'
2012-03-27T06:15:19+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/builder.rb:63:in `new'
2012-03-27T06:15:19+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/builder.rb:46:in `initialize'
2012-03-27T06:15:19+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/builder.rb:46:in `instance_eval'
2012-03-27T06:15:19+00:00 app[web.1]: from /home/heroku_rack/heroku.ru:11:in `block in <main>'
2012-03-27T06:15:19+00:00 app[web.1]: from /home/heroku_rack/heroku.ru:11:in `new'
2012-03-27T06:15:19+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/builder.rb:46:in `instance_eval'
2012-03-27T06:15:19+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/builder.rb:46:in `initialize'
2012-03-27T06:15:19+00:00 app[web.1]: from /home/heroku_rack/heroku.ru:1:in `new'
2012-03-27T06:15:19+00:00 app[web.1]: from /home/heroku_rack/heroku.ru:1:in `<main>'
2012-03-27T06:15:19+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/rack/adapter/loader.rb:36:in `eval'
2012-03-27T06:15:19+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/rack/adapter/loader.rb:36:in `load'
2012-03-27T06:15:19+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/controllers/controller.rb:175:in `load_rackup_config'
2012-03-27T06:15:19+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/runner.rb:143:in `run!'
2012-03-27T06:15:19+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/runner.rb:177:in `run_command'
2012-03-27T06:15:19+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/controllers/controller.rb:65:in `start'
2012-03-27T06:15:19+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/bin/thin:6:in `<top (required)>'
2012-03-27T06:15:19+00:00 app[web.1]: from
/usr/ruby1.9.2/bin/thin:19:in `<main>'
2012-03-27T06:15:19+00:00 app[web.1]: from /usr/ruby1.9.2/bin/thin:19:in `load'
2012-03-27T06:15:20+00:00 heroku[web.1]: Process exited with status 1
2012-03-27T06:15:20+00:00 heroku[web.1]: State changed from starting to crashed
2012-03-27T06:15:21+00:00 heroku[router]: Error H10 (App crashed) -> GET deep-sword-6479.heroku.com/ dyno= queue= wait= service= status=503 bytes=
2012-03-27T06:15:21+00:00 heroku[nginx]: 71.131.178.68 - - [27/Mar/2012:06:15:21 +0000] "GET / HTTP/1.1" 503 607 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:12.0) Gecko/20100101 Firefox/12.0" deep-sword-6479.heroku.com
2012-03-27T06:15:30+00:00 heroku[router]: Error H10 (App crashed) -> GET deep-sword-6479.heroku.com/ dyno= queue= wait= service= status=503 bytes=
2012-03-27T06:15:30+00:00 heroku[nginx]: 71.131.178.68 - - [27/Mar/2012:06:15:30 +0000] "GET / HTTP/1.1" 503 607 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:12.0) Gecko/20100101 Firefox/12.0" deep-sword-6479.heroku.com
2012-03-27T06:15:37+00:00 heroku[router]: Error H10 (App crashed) -> GET deep-sword-6479.heroku.com/ dyno= queue= wait= service= status=503 bytes=
2012-03-27T06:15:39+00:00 heroku[nginx]: 71.131.178.68 - - [27/Mar/2012:06:15:37 +0000] "GET / HTTP/1.1" 503 607 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:12.0) Gecko/20100101 Firefox/12.0" deep-sword-6479.heroku.com
2012-03-27T06:17:16+00:00 heroku[router]: Error H10 (App crashed) -> GET deep-sword-6479.heroku.com/hi dyno= queue= wait= service= status=503 bytes=
2012-03-27T06:17:16+00:00 heroku[nginx]: 85.115.194.158 - - [27/Mar/2012:06:17:16 +0000] "GET /hi HTTP/1.1" 503 607 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.65 Safari/535.11" deep-sword-6479.heroku.com
2012-03-27T06:17:17+00:00 heroku[router]: Error H10 (App crashed) -> GET deep-sword-6479.heroku.com/favicon.ico dyno= queue= wait= service= status=503 bytes=
2012-03-27T06:17:17+00:00 heroku[nginx]: 85.115.194.158 - - [27/Mar/2012:06:17:17 +0000] "GET /favicon.ico HTTP/1.1" 503 607 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.65 Safari/535.11" deep-sword-6479.heroku.com
2012-03-27T06:22:50+00:00 heroku[web.1]: State changed from crashed to created
2012-03-27T06:22:50+00:00 heroku[web.1]: State changed from created to starting
2012-03-27T06:22:52+00:00 heroku[web.1]: Starting process with command `thin -p 31779 -e production -R /home/heroku_rack/heroku.ru start`
2012-03-27T06:22:53+00:00 app[web.1]: <internal:lib/rubygems/custom_require>:29:in `require': no such file to load -- sinatra (LoadError)
2012-03-27T06:22:53+00:00 app[web.1]: from <internal:lib/rubygems/custom_require>:29:in `require'
2012-03-27T06:22:53+00:00 app[web.1]: from /app/hello.rb:2:in `<top (required)>'
2012-03-27T06:22:53+00:00 app[web.1]: from <internal:lib/rubygems/custom_require>:29:in `require'
2012-03-27T06:22:53+00:00 app[web.1]: from config.ru:1:in `block (3 levels) in <main>'
2012-03-27T06:22:53+00:00 app[web.1]: from <internal:lib/rubygems/custom_require>:29:in `require'
2012-03-27T06:22:53+00:00 app[web.1]: from /home/heroku_rack/heroku.ru:23:in `block (3 levels) in <main>'
2012-03-27T06:22:53+00:00 app[web.1]: from /home/heroku_rack/heroku.ru:23:in `eval'
2012-03-27T06:22:53+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/builder.rb:46:in `instance_eval'
2012-03-27T06:22:53+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/builder.rb:46:in `initialize'
2012-03-27T06:22:53+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/builder.rb:63:in `new'
2012-03-27T06:22:53+00:00 app[web.1]: from /home/heroku_rack/heroku.ru:18:in `block (2 levels) in <main>'
2012-03-27T06:22:53+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/builder.rb:46:in `instance_eval'
2012-03-27T06:22:53+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/builder.rb:63:in `map'
2012-03-27T06:22:53+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/builder.rb:46:in `initialize'
2012-03-27T06:22:53+00:00 app[web.1]: from /home/heroku_rack/heroku.ru:11:in `new'
2012-03-27T06:22:53+00:00 app[web.1]: from /home/heroku_rack/heroku.ru:11:in `block in <main>'
2012-03-27T06:22:53+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/builder.rb:46:in `instance_eval'
2012-03-27T06:22:53+00:00 app[web.1]: from /home/heroku_rack/heroku.ru:1:in `new'
2012-03-27T06:22:53+00:00 app[web.1]: from /home/heroku_rack/heroku.ru:1:in `<main>'
2012-03-27T06:22:53+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/rack-1.1.0/lib/rack/builder.rb:46:in `initialize'
2012-03-27T06:22:53+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/rack/adapter/loader.rb:36:in `eval'
2012-03-27T06:22:53+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/rack/adapter/loader.rb:36:in `load'
2012-03-27T06:22:53+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/controllers/controller.rb:175:in `load_rackup_config'
2012-03-27T06:22:53+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/controllers/controller.rb:65:in `start'
2012-03-27T06:22:53+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/runner.rb:143:in `run!'
2012-03-27T06:22:53+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/lib/thin/runner.rb:177:in `run_command'
2012-03-27T06:22:53+00:00 app[web.1]: from /usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/thin-1.2.6/bin/thin:6:in `<top (required)>'
2012-03-27T06:22:53+00:00 app[web.1]: from /usr/ruby1.9.2/bin/thin:19:in `load'
2012-03-27T06:22:53+00:00 app[web.1]: from /usr/ruby1.9.2/bin/thin:19:in `<main>'
2012-03-27T06:22:54+00:00 heroku[web.1]: Process exited with status 1
2012-03-27T06:22:54+00:00 heroku[web.1]: State changed from starting to crashed
答案 0 :(得分:1)
<强> hello.rb的强>
require 'rubygems'
require 'sinatra'
get '/hi' do
"Hello World!"
end
然后在同一目录中创建 config.ru 文件
require './hello'
run Sinatra::Application
然后创建 Gemfile
source 'http://rubygems.org'
gem 'sinatra'
git push heroku master, 您可以在此处查看结果:http://glowing-dusk-8900.heroku.com/
更多信息here
修改强>