将Sinatra应用程序部署到heroku

时间:2012-11-02 06:51:01

标签: heroku sinatra

我正在尝试从heroku docs部署基本的sinatra应用程序。该应用似乎正在部署和正确启动,但我看不到它。我错过了什么?

# Gemfile
source 'http://rubygems.org'
gem 'sinatra'

# config.ru
require './hello'
run Sinatra::Application

# hello.rb 
require 'sinatra'

get '/' do
  "Hello World!"
end
然后我跑了:

$ bundle install
$ git init
$ git add --all
$ git commit -m "initial commit"
$ heroku create
$ git push heroku master
$ heroku open

问题是,我得到的是“Heroku | No such app”错误。然后我尝试:

$ heroku restart
$ heroku logs

您可以在下面看到结果:

2012-11-02T06:19:24+00:00 heroku[web.1]: Unidling
2012-11-02T06:19:24+00:00 heroku[web.1]: State changed from down to starting
2012-11-02T06:19:27+00:00 heroku[web.1]: Starting process with command `bundle exec rackup config.ru -p 38715`
2012-11-02T06:19:31+00:00 app[web.1]: [2012-11-02 06:19:31] INFO  WEBrick 1.3.1
2012-11-02T06:19:31+00:00 app[web.1]: [2012-11-02 06:19:31] INFO  ruby 1.9.2 (2011-07-09 [x86_64-linux]
2012-11-02T06:19:31+00:00 app[web.1]: [2012-11-02 06:19:31] INFO WEBrick::HTTPServer#start: pid=2 port=38715
2012-11-02T06:19:32+00:00 heroku[web.1]: State changed from starting to up

1 个答案:

答案 0 :(得分:0)

我刚刚尝试了这些完全相同的步骤,它运行得很好。不知道之前出了什么问题。

昨晚我改为:

# hello.rb 
require 'sinatra'

class HelloApp < Sinatra::Base
  get '/' do
    "Hello World!"
  end
end

# config.ru
require './hello'
run HelloApp

它有效。不知道为什么,但确实如此。奇

相关问题