在Heroku上部署Sinatra应用程序 [英] Deploy Sinatra app on Heroku
本文介绍了在Heroku上部署Sinatra应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
$ b web.rb:
require'sinatra'
get'/'do
Hello
end
Gemfile:*
source:rubygems
gem'sinatra','1.1.0'
gem'thin','1.2.7'
$ b config.ru:
require'./web'
run Sinatra :: Application
但是当我部署我的应用在Heroku上我会得到日志上的错误:
2012-03-27T19:17:48 + 00:00 heroku [路由器]:错误H14(没有web进程运行) - > GET furious-waterfall-6586.herokuapp.com/ dyno = queue = wait = service = status = 503 bytes =
如何修复它?
解决方案
您需要一个 Procfile
文件旁边的 config.ru
来告诉Heroku如何运行你的应用程序。这里是一个示例 Procfile
的内容:
web:bundle exec ruby web.rb -p $ PORT
编辑:这里有一个示例 config。 ru
从我的一个sinatra / Heroku应用程序: $ :. unshift File.expand_path( ../,__FILE__)
require'rubygems'
require'sinatra'
require'./web'
运行Sinatra :: Application
您可能需要使用sinatra和rubygems才能正常工作。
I have simple Sinatra app.
web.rb:
require 'sinatra'
get '/' do
"Hello"
end
Gemfile:*
source :rubygems
gem 'sinatra', '1.1.0'
gem 'thin', '1.2.7'
config.ru:
require './web'
run Sinatra::Application
But when I deploy my app on Heroku I'll get the error on logs:
2012-03-27T19:17:48+00:00 heroku[router]: Error H14 (No web processes running) -> GET furious-waterfall-6586.herokuapp.com/ dyno= queue= wait= service= status=503 bytes=
How can I fix it?
解决方案
You need a Procfile
file alongside your config.ru
to tell Heroku how to run your app. Here is the content of an example Procfile
:
web: bundle exec ruby web.rb -p $PORT
EDIT: Here's a sample config.ru
from one of my sinatra/Heroku apps:
$:.unshift File.expand_path("../", __FILE__)
require 'rubygems'
require 'sinatra'
require './web'
run Sinatra::Application
You may need to require sinatra and rubygems for it to work.
这篇关于在Heroku上部署Sinatra应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文