Heroku is a cloud platform as a service (PaaS) supporting several programming languages. Heroku is owned by Salesforce.com. Heroku, one of the first cloud platforms, has been in development since June 2007 when it supported the Ruby programming language, but since has added support for Java, Node.js, Scala, Clojure and Python and (undocumented) PHP. The base operating system is Debian or the Debian-based Ubuntu in the newest stack.

At its core, Heroku is just a simple unix platform; specifically, Ubuntu 10.04 LTS.
$heroku run bash
Running `bash` attached to terminal… up, run.1
$ uname -a
Linux f780edbd-5880-44f1-b3f3-ce436852324f 2.6.32-343-ec2 #45+lp929941v1 SMP Tue Feb 21 14:07:44 UTC 2012 x86_64 GNU/Linux

$ cat /etc/issue
Ubuntu 10.04 LTS \n \l

$cat /proc/cupinfo

512MB of RAM, 1GB of swap. Total = 1.5GB RAM.
4 CPU cores (Intel Xeon X5550 @ 2.67GHz).
Isolated execution. Anything you store on your dyno will be isolated from all other dynos.

$ cat /proc/meminfo

MemTotal:       35861696 kB
MemFree:         2016652 kB
Buffers:         7816724 kB
Cached:          7798292 kB
SwapCached:       731704 kB
Active:         21861424 kB
Inactive:        8557072 kB
Active(anon):   13522104 kB
Inactive(anon):  1328344 kB
Active(file):    8339320 kB
….many more

Getting Started with Rails3 on Heroku

After creating rails3 application on you local system
Go to app’s root dir and reate a git repo
$ git init
$ git add .
$ git commit -m “init commit”

Deploy to Heroku/Cedar
before deployiong add thse gems in your Gemfile
group :production do
gem ‘thin’
gem ‘pg’

$ bundle install
Create one file named Procfile in you application’s root dir
and put this line
web: bundle exec rails server thin -p $PORT

Save the canges and commit your changes to Git
$ git add .
$ git commit -m “use thin via procfile”

Now deploying to Heroku

$ heroku create your-application-name # will create a new application name for you
$ git push heroku master # will deploy your application on heroku
$ heroku run rake db:migrate #will do migration
$ heroku open # will open your application in browser
$ heroku ps  # will show about state of the app’s processes:
$ heroku logs # will give you production logs
$ heroku run console # will give you console
$ heroku run rake -T


More commands line tools:
$ heroku help
$ heroku info
$ heroku stack
$ heroku open
$ heroku ps
$ heroku logs
$ heroku logs –tail
$ heroku logs -n 200
$ heroku logs –ps run
$ heroku logs -p worker -t
$ heroku run rails console
$ heroku run rails server
$ heroku run ‘ruby -v’
$ heroku run ‘ruby -e “puts RUBY_VERSION”‘
$ heroku run date
$ heroku run rake -T
$ heroku config
$ heroku config | grep REDIS
$ heroku restart
$ heroku run rake db:migrate
$ heroku run rake db:seed
$ heroku run rake db:setup
$ heroku pg:reset SHARED_DATABASE –confirm myapp
$ git push heroku production:master #heroku use specific branch at production
$ heroku run curl http://www.google.com/
$ heroku run bash # you can try some linux thing

$ heroku run ruby scripts/fix_bad_records.rb

When you are done, press Ctrl-C to close the session.

Release management
All application deployments and configuration changes are captured and logged by Heroku and are made available with heroku releases.

$ heroku releases
$ heroku releases:info v24
$ heroku rollback # will Rolled back to previous release
$ heroku releases:rollback.
Reference : Heroku document is well written.

Heroku working : http://www.heroku.com/how

Heroku for ruby : https://devcenter.heroku.com/categories/ruby




Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s