我的所有文件都可以在GitHub上找到:https://github.com/Integralist/Passage(以防您需要查看我正在使用的内容)。
我是Heroku的新用户,我尝试按照上传Sinatra应用程序的说明进行操作,但它没有运行,当我访问应用程序URL时,我收到一条通用的“应用程序错误”消息。
我的设置过程如下:
heroku login
heroku create --stack cedar
创建config.ru
文件并添加内容...
require 'app'
run Sinatra::Application
创建Gemfile文件(无文件扩展名)并添加内容...
source 'http://rubygems.org'
gem 'sinatra', '1.3.2'
gem 'thin', '1.3.1'
打开终端(我正在运行Mac OS X)并执行:bundle install
这似乎生成了一个重复的Gemfile但这次使用.lock文件扩展名?这个其他Gemfile现在有以下内容......
GEM
remote: http://rubygems.org/
specs:
daemons (1.1.8)
eventmachine (0.12.10)
rack (1.4.1)
rack-protection (1.2.0)
rack
sinatra (1.3.2)
rack (~> 1.3, >= 1.3.6)
rack-protection (~> 1.2)
tilt (~> 1.3, >= 1.3.3)
thin (1.3.1)
daemons (>= 1.0.9)
eventmachine (>= 0.12.6)
rack (>= 1.0.0)
tilt (1.3.3)
PLATFORMS
ruby
DEPENDENCIES
sinatra (= 1.3.2)
thin (= 1.3.1)
然后我创建一个Procfile
(没有文件扩展名)并添加内容:web: bundle exec ruby app.rb -p $PORT
(app.rb显然是我的主应用程序文件的名称)。
然后我使用Git将我的文件暂存/提交/推送到相关的Heroku repo。
但如果我跑heroku ps
我就会......
=== web: `bundle exec ruby app.rb -p`
web.1: crashed for 1m
然后如果我跑heroku logs
我就会......
2012-06-09T18:35:41+00:00 heroku[slugc]: Slug compilation started
2012-06-09T18:36:37+00:00 heroku[api]: Add LANG, PATH, RACK_ENV, GEM_PATH config by email@domain.com
2012-06-09T18:36:37+00:00 heroku[api]: Release v2 created by email@domain.com
2012-06-09T18:36:38+00:00 heroku[api]: Release v3 created by email@domain.com
2012-06-09T18:36:38+00:00 heroku[api]: Deploy e26921b by email@domain.com
2012-06-09T18:36:38+00:00 heroku[web.1]: State changed from created to starting
2012-06-09T18:36:38+00:00 heroku[slugc]: Slug compilation finished
2012-06-09T18:36:40+00:00 heroku[web.1]: Starting process with command `bundle exec ruby app.rb -p`
2012-06-09T18:36:41+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.2/lib/sinatra/main.rb:15:in `<class:Application>': missing argument: -p (OptionParser::MissingArgument)
2012-06-09T18:36:41+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.2/lib/sinatra/main.rb:4:in `<module:Sinatra>'
2012-06-09T18:36:41+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.2/lib/sinatra/main.rb:3:in `<top (required)>'
2012-06-09T18:36:41+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.2/lib/sinatra.rb:5:in `require'
2012-06-09T18:36:41+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.2/lib/sinatra.rb:5:in `<top (required)>'
2012-06-09T18:36:41+00:00 app[web.1]: from app.rb:12:in `require'
2012-06-09T18:36:41+00:00 app[web.1]: from app.rb:12:in `<main>'
2012-06-09T18:36:42+00:00 heroku[web.1]: Process exited with status 1
2012-06-09T18:36:42+00:00 heroku[web.1]: State changed from starting to crashed
2012-06-09T18:36:42+00:00 heroku[web.1]: State changed from crashed to created
2012-06-09T18:36:42+00:00 heroku[web.1]: State changed from created to starting
2012-06-09T18:36:44+00:00 heroku[web.1]: Starting process with command `bundle exec ruby app.rb -p`
2012-06-09T18:36:45+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.2/lib/sinatra/main.rb:15:in `<class:Application>': missing argument: -p (OptionParser::MissingArgument)
2012-06-09T18:36:45+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.2/lib/sinatra/main.rb:4:in `<module:Sinatra>'
2012-06-09T18:36:45+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.2/lib/sinatra/main.rb:3:in `<top (required)>'
2012-06-09T18:36:45+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.2/lib/sinatra.rb:5:in `require'
2012-06-09T18:36:45+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.2/lib/sinatra.rb:5:in `<top (required)>'
2012-06-09T18:36:45+00:00 app[web.1]: from app.rb:12:in `require'
2012-06-09T18:36:45+00:00 app[web.1]: from app.rb:12:in `<main>'
2012-06-09T18:36:47+00:00 heroku[web.1]: Process exited with status 1
2012-06-09T18:36:47+00:00 heroku[web.1]: State changed from starting to crashed
2012-06-09T18:42:09+00:00 heroku[router]: Error H10 (App crashed) -> GET furious-wind-9309.herokuapp.com/ dyno= queue= wait= service= status=503 bytes=
2012-06-09T18:42:09+00:00 heroku[router]: Error H10 (App crashed) -> GET furious-wind-9309.herokuapp.com/favicon.ico dyno= queue= wait= service= status=503 bytes=
2012-06-09T18:42:38+00:00 heroku[router]: Error H10 (App crashed) -> GET furious-wind-9309.herokuapp.com/ dyno= queue= wait= service= status=503 bytes=
2012-06-09T18:42:39+00:00 heroku[router]: Error H10 (App crashed) -> GET furious-wind-9309.herokuapp.com/favicon.ico dyno= queue= wait= service= status=503 bytes=
有人可以解释问题是什么以及如何解决它。
感谢。
答案 0 :(得分:1)
/app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.2/lib/sinatra/main.rb:15:in `<class:Application>': missing argument: -p (OptionParser::MissingArgument)
这是它在堆栈跟踪中给出的错误。当它运行bundle exec ruby app.rb -p
时,没有给出-p
的参数。您需要bundle exec ruby app.rb -p 3000
之类的东西(在端口3000上运行)。也许全局变量$ PORT没有被定义?
修改
虽然形成heroku's docs on the Procfile:
You can reference other environment variables populated by Heroku, most usefully the $PORT variable, in the command.
尝试执行raise $PORT.inspect
,然后推送到heroku。它会崩溃,但希望更好地了解它正在尝试做什么。