Sinat的应用程序部署到Heroku失败了

时间:2018-03-22 19:22:01

标签: heroku deployment sinatra

这是一个简单的2页Sinatra应用程序,Heroku会返回以下错误消息。

我尝试将config.ruapp.rb置于app folder和根路径下方 但两者都不起作用......

我错过了什么吗?

2018-03-22T18:40:51.490531+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.4.0/bin/rackup:23:in `load'
2018-03-22T18:40:51.490533+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.4.0/bin/rackup:23:in `<top (required)>'
2018-03-22T18:40:53.657577+00:00 heroku[web.1]: Starting process with command `bundle exec rackup config.ru -p 22470`
2018-03-22T18:40:55.804338+00:00 heroku[web.1]: Process exited with status 1
2018-03-22T18:40:55.821099+00:00 heroku[web.1]: State changed from starting to crashed
2018-03-22T18:40:55.675952+00:00 app[web.1]: bundler: failed to load command: rackup (/app/vendor/bundle/ruby/2.4.0/bin/rackup)
2018-03-22T18:40:55.675970+00:00 app[web.1]: LoadError: cannot load such file -- ./app
2018-03-22T18:40:55.675972+00:00 app[web.1]:   /app/config.ru:1:in `require'
2018-03-22T18:40:55.675973+00:00 app[web.1]:   /app/config.ru:1:in `block in <main>'
2018-03-22T18:40:55.675974+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.4.0/gems/rack-2.0.4/lib/rack/builder.rb:55:in `instance_eval'
2018-03-22T18:40:55.675976+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.4.0/gems/rack-2.0.4/lib/rack/builder.rb:55:in `initialize'
2018-03-22T18:40:55.675977+00:00 app[web.1]:   /app/config.ru:in `new'
2018-03-22T18:40:55.675978+00:00 app[web.1]:   /app/config.ru:in `<main>'
2018-03-22T18:40:55.675980+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.4.0/gems/rack-2.0.4/lib/rack/builder.rb:49:in `eval'
2018-03-22T18:40:55.675981+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.4.0/gems/rack-2.0.4/lib/rack/builder.rb:49:in `new_from_string'
2018-03-22T18:40:55.675983+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.4.0/gems/rack-2.0.4/lib/rack/builder.rb:40:in `parse_file'
2018-03-22T18:40:55.675985+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.4.0/gems/rack-2.0.4/lib/rack/server.rb:319:in `build_app_and_options_from_config'
2018-03-22T18:40:55.675986+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.4.0/gems/rack-2.0.4/lib/rack/server.rb:219:in `app'
2018-03-22T18:40:55.675988+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.4.0/gems/rack-2.0.4/lib/rack/server.rb:354:in `wrapped_app'
2018-03-22T18:40:55.675990+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.4.0/gems/rack-2.0.4/lib/rack/server.rb:283:in `start'
2018-03-22T18:40:55.675991+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.4.0/gems/rack-2.0.4/lib/rack/server.rb:148:in `start'
2018-03-22T18:40:55.675993+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.4.0/gems/rack-2.0.4/bin/rackup:4:in `<top (required)>'
2018-03-22T18:40:55.675995+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.4.0/bin/rackup:23:in `load'
2018-03-22T18:40:55.675997+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.4.0/bin/rackup:23:in `<top (required)>'


2018-03-22T18:44:05.000000+00:00 app[api]: Build succeeded
2018-03-22T18:44:40.562559+00:00 heroku[web.1]: State changed from crashed to starting
2018-03-22T18:44:42.586913+00:00 heroku[web.1]: Starting process with command `bundle exec rackup config.ru -p 5319`
2018-03-22T18:44:45.148047+00:00 heroku[web.1]: Process exited with status 1
2018-03-22T18:44:45.168235+00:00 heroku[web.1]: State changed from starting to crashed
2018-03-22T18:44:45.025605+00:00 app[web.1]: bundler: failed to load command: rackup (/app/vendor/bundle/ruby/2.4.0/bin/rackup)
2018-03-22T18:44:45.025629+00:00 app[web.1]: LoadError: cannot load such file -- sinatra/link_header
2018-03-22T18:44:45.025631+00:00 app[web.1]:   /app/app/app.rb:2:in `require'
2018-03-22T18:44:45.025632+00:00 app[web.1]:   /app/app/app.rb:2:in `<top (required)>'
2018-03-22T18:44:45.025634+00:00 app[web.1]:   /app/config.ru:1:in `require'
2018-03-22T18:44:45.025635+00:00 app[web.1]:   /app/config.ru:1:in `block in <main>'
2018-03-22T18:44:45.025637+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.4.0/gems/rack-2.0.4/lib/rack/builder.rb:55:in `instance_eval'
2018-03-22T18:44:45.025638+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.4.0/gems/rack-2.0.4/lib/rack/builder.rb:55:in `initialize'
2018-03-22T18:44:45.025641+00:00 app[web.1]:   /app/config.ru:in `<main>'
2018-03-22T18:44:45.025640+00:00 app[web.1]:   /app/config.ru:in `new'
2018-03-22T18:44:45.025642+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.4.0/gems/rack-2.0.4/lib/rack/builder.rb:49:in `eval'
2018-03-22T18:44:45.025644+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.4.0/gems/rack-2.0.4/lib/rack/builder.rb:49:in `new_from_string'
2018-03-22T18:44:45.025646+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.4.0/gems/rack-2.0.4/lib/rack/builder.rb:40:in `parse_file'
2018-03-22T18:44:45.025647+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.4.0/gems/rack-2.0.4/lib/rack/server.rb:319:in `build_app_and_options_from_config'
2018-03-22T18:44:45.025649+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.4.0/gems/rack-2.0.4/lib/rack/server.rb:219:in `app'
2018-03-22T18:44:45.025651+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.4.0/gems/rack-2.0.4/lib/rack/server.rb:354:in `wrapped_app'
2018-03-22T18:44:45.025652+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.4.0/gems/rack-2.0.4/lib/rack/server.rb:283:in `start'
2018-03-22T18:44:45.025654+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.4.0/gems/rack-2.0.4/lib/rack/server.rb:148:in `start'
2018-03-22T18:44:45.025655+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.4.0/gems/rack-2.0.4/bin/rackup:4:in `<top (required)>'
2018-03-22T18:44:45.025657+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.4.0/bin/rackup:23:in `load'
2018-03-22T18:44:45.025659+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.4.0/bin/rackup:23:in `<top (required)>'

2018-03-22T19:04:36.398574+00:00 heroku[web.1]: Restarting
2018-03-22T19:04:36.399250+00:00 heroku[web.1]: State changed from up to starting
2018-03-22T19:04:37.265389+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2018-03-22T19:04:37.446567+00:00 heroku[web.1]: Process exited with status 1
2018-03-22T19:04:37.288342+00:00 app[web.1]: [4] - Gracefully shutting down workers...
2018-03-22T19:04:37.301303+00:00 app[web.1]: bundler: failed to load command: rackup (/app/vendor/bundle/ruby/2.4.0/bin/rackup)
2018-03-22T19:04:37.301330+00:00 app[web.1]: SignalException: SIGTERM
2018-03-22T19:04:37.301336+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.4.0/gems/puma-3.11.3/lib/puma/cluster.rb:381:in `block in setup_signals'
2018-03-22T19:04:37.301338+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.4.0/gems/puma-3.11.3/lib/puma/cluster.rb:475:in `select'
2018-03-22T19:04:37.301339+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.4.0/gems/puma-3.11.3/lib/puma/cluster.rb:475:in `run'
2018-03-22T19:04:37.301340+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.4.0/gems/puma-3.11.3/lib/puma/launcher.rb:183:in `run'
2018-03-22T19:04:37.301341+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.4.0/gems/puma-3.11.3/lib/rack/handler/puma.rb:69:in `run'
2018-03-22T19:04:37.301343+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.4.0/gems/rack-2.0.4/lib/rack/server.rb:297:in `start'
2018-03-22T19:04:37.301344+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.4.0/gems/rack-2.0.4/lib/rack/server.rb:148:in `start'
2018-03-22T19:04:37.301345+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.4.0/gems/rack-2.0.4/bin/rackup:4:in `<top (required)>'
2018-03-22T19:04:37.301347+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.4.0/bin/rackup:23:in `load'
2018-03-22T19:04:37.301392+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.4.0/bin/rackup:23:in `<top (required)>'
2018-03-22T19:04:38.773020+00:00 heroku[web.1]: Starting process with command `bundle exec rackup config.ru -p 16845`
2018-03-22T19:04:40.529326+00:00 heroku[web.1]: Process exited with status 1
2018-03-22T19:04:40.538335+00:00 heroku[web.1]: State changed from starting to crashed
2018-03-22T19:04:40.541186+00:00 heroku[web.1]: State changed from crashed to starting
2018-03-22T19:04:40.428727+00:00 app[web.1]: configuration /app/config.ru not found
2018-03-22T19:04:42.516252+00:00 heroku[web.1]: Starting process with command `bundle exec rackup config.ru -p 3071`
2018-03-22T19:04:44.810385+00:00 heroku[web.1]: Process exited with status 1
2018-03-22T19:04:44.823666+00:00 heroku[web.1]: State changed from starting to crashed
2018-03-22T19:04:44.653840+00:00 app[web.1]: configuration /app/config.ru not found

1 个答案:

答案 0 :(得分:0)

我刚做了测试,写了一个非常简单的Sinatra应用程序并将其推送到Heroku。

的Gemfile

source 'https://rubygems.org'

ruby '2.4.0'
gem 'sinatra'

config.ru

require './app'
run Sinatra::Application

app.rb

require 'sinatra'

get '/' do
  "Hello world"
end

此时启动rackup在本地完美运行,但是当我推送到heroku时,我也遇到了错误,就像你一样。看起来我错过了Procfile。然后我添加了一个简单的Procfile来告诉Heroku运行应用程序时应该启动什么:

Procfile

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

所以在这一点上,我得到了这个文件层次结构:

App directory
 \ 
  |– Gemfile
  |– config.ru
  |– app.rb
  |– Procfile

而且,它现在完美无缺。可能值得一试并将这种Procfile添加到您的项目中。您可以在Heroku Getting started on Heroku with Ruby : Procfile及其devcenter article about process types and Procfiles上找到有关Procfile的更多详细信息。