Saturday, 23 April 2011

RoR heroku deployment

Heroku
Heroku is best known for Ruby On Rails hosting. It's world class service place it apart from others.

Best thing about Heroku is that it also provide a free hosting of 100mb diskspace and 5mb of Database.
Enough to get you started with ror project deployment.

since creating account on heroku is free you can also create create and deploy facebook on heroku for free.

Here are the step:


If you've read my previous article  on using Git on ubuntu , please proceed reading otherwise i strongly recommend you to go through that article first.


move into your project directory. For.eg let say my project name is "cronfarm" . so.

$ cd  /cronfarm

#install heroku gem
$ sudo gem install heroku 
$ heroku keys:add  in you ssh list
#to add public key

#create subdomain of your choice OR let heroku generate a randome subdomain for you.
$ heroku create  "MyCustomeSubDomain"
#it will create a MYCustomeSubDomain.heroku.com
OR
$ heroku create 
# it will generate a subdomain like  " kitana.heroku.com, dokodeskh.heroku.com etc"
 Or
$heroku create --stack cedar
#if you want to use cedar runtime stack

verify it :
$git remote -v
#it will list all the remote repository currently added in your app. If you find your heroku remote added , then you're good to go.

To rename your existing subdomain , try this
$ heroku rename myNewSubDomain
#it'll change your app url to myNewSubDomain.heroku.com

If you have you own domain you wanna use please refer this article :Custom Domain

Once done, creating a subdomain, it's time to upload your files and database which is very much similar to git command of commit and merge

To deploy:
$ git  push heroku master
#it will push your master branch on the heroku

$ heroku rake db:migrate  ==>$heroku run rake db:migrate
#it will create database on the heroku server. Only schema/tables/

$ heroku db:push 
#it will push all your database tables entries on heroku server. (All tuples)


Setting up config vars for a deployed application

Use the Heroku CLI’s config, config:add, and config:remove to manage your config vars:
$heroku config #it will list down all the already set envioronment variables
$heroku config:add USERNAME=john  PASSWORD=xxxx#it'll set the USERNAME and PASSWORD in the environment

open the url
$  heroku open
# it will open the url in new browser window


To check heroku logs
$ heroku logs
#it will fetch and show you the latest update in the log entry, around 100 lines. To see all rest of the log, you'll be needed a heroku's  'loggin-basic' addon


Optionals:
You can extend heroku functionaliy by adding Addons
To Add more heroku Addons
$ heroku addons:add logging:basic
# now you can view logs upto 500 lines
$ heroku logs -n 500


Best is:
$ heroku addons:upgrate logging:expanded
$ heroku logs --tail

To install memcached addon
$ heroku addons:add memcached

1 comment:

  1. for cedar app:
    $ heroku create --stack cedar
    Creating falling-wind-1624... done, stack is cedar
    http://falling-wind-1624.herokuapp.com/ | git@heroku.com:falling-wind-1624.git
    Git remote heroku added

    And for db migrate:
    heroku run rake db:migrate

    ReplyDelete