Can';你不能让基本的Ruby/Sinatra应用程序与Heroku一起工作吗?
我的所有文件都可以在GitHub上找到:(以防万一你需要了解我的工作内容) 我是Heroku的新手,我尝试按照说明上传Sinatra应用程序,但它无法运行,当我访问应用程序URL时,我会收到一条通用的“应用程序错误”消息 我的设置过程如下:Can';你不能让基本的Ruby/Sinatra应用程序与Heroku一起工作吗?,ruby,heroku,Ruby,Heroku,我的所有文件都可以在GitHub上找到:(以防万一你需要了解我的工作内容) 我是Heroku的新手,我尝试按照说明上传Sinatra应用程序,但它无法运行,当我访问应用程序URL时,我会收到一条通用的“应用程序错误”消息 我的设置过程如下: heroku登录 heroku创建——stack cedar 创建config.ru文件并添加内容 require 'app' run Sinatra::Application source 'http://rubygems.org' gem 'sin
heroku登录
heroku创建——stack cedar
config.ru
文件并添加内容
require 'app'
run Sinatra::Application
source 'http://rubygems.org'
gem 'sinatra', '1.3.2'
gem 'thin', '1.3.1'
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)
创建一个Gemfile文件(无文件扩展名)并添加内容
require 'app'
run Sinatra::Application
source 'http://rubygems.org'
gem 'sinatra', '1.3.2'
gem 'thin', '1.3.1'
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)
打开终端(我正在运行Mac OS X)并执行:bundle install
,它似乎生成了一个重复的GEM文件,但这次是一个.lock文件扩展名?此其他文件现在具有以下内容
require 'app'
run Sinatra::Application
source 'http://rubygems.org'
gem 'sinatra', '1.3.2'
gem 'thin', '1.3.1'
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
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=
然后如果我运行heroku日志,我会得到
=== web: `bundle exec ruby app.rb -p`
web.1: crashed for 1m
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=
2012-06-09T18:35:41+00:00 heroku[slugc]:Slug编译已开始
2012-06-09T18:36:37+00:00 heroku[api]:添加LANG、PATH、RACK_ENV、GEM_PATH配置email@domain.com
2012-06-09T18:36:37+00:00 heroku[api]:版本v2由创建email@domain.com
2012-06-09T18:36:38+00:00 heroku[api]:v3版由创建email@domain.com
2012-06-09T18:36:38+00:00 heroku[api]:部署e26921bemail@domain.com
2012-06-09T18:36:38+00:00 heroku[web.1]:状态从创建更改为开始
2012-06-09T18:36:38+00:00 heroku[slugc]:Slug编译完成
2012-06-09T18:36:40+00:00 heroku[web.1]:使用命令“bundle exec ruby app.rb-p”启动进程`
2012-06-09T18:36:41+00:00应用程序[web.1]:/app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.2/lib/sinatra/main.rb:15:in`':缺少参数:-p(OptionParser::MissingArgument)
2012-06-09T18:36:41+00:00应用程序[web.1]:from/app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.2/lib/sinatra/main.rb:4:in`'
2012-06-09T18:36:41+00:00应用程序[web.1]:from/app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.2/lib/sinatra/main.rb:3:in`'
2012-06-09T18:36:41+00:00应用程序[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应用程序[web.1]:from/app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.2/lib/sinatra.rb:5:in`'
2012-06-09T18:36:41+00:00应用程序[web.1]:来自应用程序rb:12:在'require'中
2012-06-09T18:36:41+00:00应用程序[web.1]:来自app.rb:12:in`'
2012-06-09T18:36:42+00:00 heroku[web.1]:进程已退出,状态为1
2012-06-09T18:36:42+00:00 heroku[web.1]:状态从开始更改为崩溃
2012-06-09T18:36:42+00:00 heroku[web.1]:状态从崩溃更改为已创建
2012-06-09T18:36:42+00:00 heroku[web.1]:状态从创建更改为启动
2012-06-09T18:36:44+00:00 heroku[web.1]:使用命令“bundle exec ruby app.rb-p”启动进程`
2012-06-09T18:36:45+00:00应用程序[web.1]:/app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.2/lib/sinatra/main.rb:15:in`':缺少参数:-p(OptionParser::MissingArgument)
2012-06-09T18:36:45+00:00应用程序[web.1]:from/app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.2/lib/sinatra/main.rb:4:in`'
2012-06-09T18:36:45+00:00应用程序[网站1]:from/app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.2/lib/sinatra/main.rb:3:in`'
2012-06-09T18:36:45+00:00应用程序[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应用程序[网站1]:from/app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.3.2/lib/sinatra.rb:5:in`'
2012-06-09T18:36:45+00:00应用程序[web.1]:来自应用程序rb:12:在'require'中
2012-06-09T18:36:45+00:00应用程序[web.1]:来自app.rb:12:in`'
2012-06-09T18:36:47+00:00 heroku[web.1]:进程已退出,状态为1
2012-06-09T18:36:47+00:00 heroku[web.1]:状态从开始更改为崩溃
2012-06-09T18:42:09+00:00 heroku[路由器]:错误H10(应用程序崩溃)->愤怒起来-wind-9309.herokuapp.com/dyno=queue=wait=service=status=503字节=
2012-06-09T18:42:09+00:00 heroku[路由器]:错误H10(应用程序崩溃)->愤怒-风-9309.herokuapp.com/favicon.ico dyno=queue=wait=service=status=503字节=
2012-06-09T18:42:38+00:00 heroku[路由器]:错误H10(应用程序崩溃)->愤怒起来-wind-9309.herokuapp.com/dyno=queue=wait=service=status=503字节=
2012-06-09T18:42:39+00:00 heroku[路由器]:错误H10(应用程序崩溃)->暴怒-风-9309.herokuapp.com/favicon.ico dyno=queue=wait=service=status=503字节=
有人能解释一下问题是什么,我如何解决它吗
谢谢
/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)
尝试执行
raise$PORT。检查,然后按下heroku。它将崩溃,但希望能更好地了解它正在尝试做什么。对于Heroku,您肯定应该使用$PORT,因为Heroku的动态特性意味着它需要传递一个端口供应用程序使用,并且没有静态可用的端口。看看,$PORT
实际上完全不存在(不管问题怎么说).By George,@matt是对的!这几乎缩小了问题的范围。谢谢大家。虽然我确信我添加了$PORT,但它显然被删除了?你的app.rb
中有什么?因为你使用的是Procfile
,你的config.ru
并没有初始化服务器,app.rb
(从ruby app.rb
命令)。