Random thoughts of a warped mind…

May 24, 2013

Sinatra app on Redhats OpenShift PaaS

Filed under: Development,EC2,Git,Linux,Redhat OpenShift,Ruby,Virtualization — Srinivas @ 02:08

Got to poke around a bit today into Redhats Open Shift PaaS… This is quite similar to Herokus platform in the sense you could pick up a “dev platform”, build an app locally and push it to the PaaS and run it from there…

For the impatient, rush over to the App on Openshift and  pull the code from github

  1. OpenShift also seems to run on Amazon EC2 (Just like Heroku does). But for the timebeing seems limited to US-East region only?
  2. It was a surprise to see Redhat using AWS – I thought they would have built their own! :-( Guess Amazon _is_ taking over the world…?
  3. Sign up on OpenShift and just like with Heroku, you push a SSH public key to your Openshift account and use it for all git related activity. You could also set a “unique” namespace that will always be suffixed to your appname (handy, I wish heroku had that and the standardized app naming schema open shift does!).
  4. Make sure you have git, ruby 1.9.x (preferred), install the rwc gem and then run “rwc setup” to setup the command line tool rwc on your machine. (This is the open shift equivalent of Herokus heroku cmd line tool)
  5. While Heroku seems to hide away the EC2 related details, Open Shift does’nt – So using Ohai its easy to look into the system to get an idea of how many other “Guest users” are on the box, the size and memory etc (FYI – A guest user is someone like you who has an app running on that box). Look at my test app at Openshiftto see what I mean… I could see 491 guest users in all on a m1.large instance – granted my app was’nt doing much but the instance did’nt seem too loaded (I could ssh into it and see mem usage, load etc as well!).

    SSH to the openshift instance

  6. I create a test app using the Ruby 1.9 cartridge called “sinner” with no load balancing (for later). This gets you a Git path like “ssh://numericid@<appname>-<namespace>.rhcloud.com/~/git/appname.git/”. Git clone that locally, This got me a config.ru (among others) that I promptly renamed to config.ru.unused and replaced with a basic config.ru suited for running Sinatra (modular app).
  7. Pick up the code for the whole thing from Sinatra on Redhat Openshift from my git repo.
  8. Commit and push to openshift Git (i.e. path from #5) to deploy app to the provider:
  9. Git push to Openshift and app deploymentRunning “rhc apps” will list all the apps and their urls as well as SSH endpoint to get into them and poke around (I love that! +1 for openshift over Heroku!).

Powered by WordPress