ITeye博客

在heroku上部署sinatra应用

bellstar · 2014-01-08 12:28 · ruby · 编程语言 · Markdown

本文假定你已经拥有了heroku账号和成功安装heroku toolbelt。如果你还没有这么做,可以看这里https://devcenter.heroku.com/articles/quickstart

  1. 在https://dashboard.heroku.com/apps页面中选择Create a new app

  2. 输入app的名字,完成创建

  3. clone项目git clone git@heroku.com:appname.git -o heroku

  4. 创建Gemfile

    
    source "https://rubygems.org"
    ruby "1.9.3"
    gem 'sinatra', '1.4.4'
    
    
  5. 创建web.rb作为web服务启动文件

    
    require "sinatra"
    
    get "/:name.html" do
      erb params[:name].to_sym
    end
    
    
  6. 创建Procfile,foreman这个gem要用它作为配置,heroku通过foreman启动web服务

    web: bundle exec ruby web.rb -p $PORT
    
  7. 创建app需要的其他文件

  8. 添加文件到git中:git add . -m "add all"

  9. 登录heroku:heroku login

  10. 发布git push heroku master

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。