Wednesday, August 13, 2014

Deploy Node.js Application on Openshift Hybrid Cloud - i-visionblog

Nowadays Developers/End users prefer cloud services for their Usage,Storage and Demanding service in one clicks either using credit cards for paying the usage.Business start ups / Developers prefer to host their applications on cloud public for users access, and to manage a huge data ,analyse by powerful cloud machines provided by cloud service providers.Where Business peoples/Developers and others can forget their Hardware specifications and start involving in the Application designs and management.Cloud plays important part in business side data/analytics handling!

Deploy Node.js Application on Openshift Hybrid Cloud - i-visionblog

Article About Cloud at i-visionblog : 

  1. What is Cloud Computing ?  - A Good Explanation for Easy Understanding with Video.
  2. Deploy PHP application - Heroku Cloud [ free untill you add add-ons]
  3. Deploy PHP application+IBM Bluemix Cloud [free trial Period ]
  4. Deploy Node.js Application+IBM Bluemix Cloud Foundry
  5. Deploy Mobile Application DataStore online - [ Free for Personal apps ]

Scope : 

Here You can develop a simple Node.js Application at Localhost and make it as deployable at Openshift(Red Hat) .

Installation : (Windows Machine ) :

  • Download GIT command line and make sure accessible via command Line [ git --version  must output with version number] click here to download.
  • Download Ruby Installer [ Stable version ] from here Must be accessible via command line.
  • once all goes well do  C:\> gem install rhc  Must Install you with RHC Client for windows.
  • Go to Red Hat Openshift Website and create a Account & then  Create a Domain name.  
This is Enough to Deploy your app in minutes from desktop.however Mac,Linux others can follow deploy process which is same since Git is Standard.Installation can differ.

RHC Setup :

 C:\ >  rhc setup 

It may prompt you for Adding server host ! Just Skip it by Pressing Enter can add it later too.
Then It may ask you to login with openshift account online emailID and Password in CMD if you're doing it first time.
And allow to add a Private SSH file for authentication purpose - RSA public key adding it permanently on you command line for 30 days life time.Enter "yes" to accept and proceed.

Creating Application :

 I would Generally appreciate you to Go to Openshift website to have Overview of application present.
There are lot of application present to be installed.
  • Add Node.js Application by clicking add application
  • Name your application [ Note that you must have added Domain Name already after sign up ]
  • And Add a custom Url for your application - [ can be changed if you have DNS records ]
  • Git repo is optional here 
  • If you want to scale application for more users,Do load balancing here- [note if you have database in application make sure it is shared across application on different instance shares it]
  • Create Application and Get the Source url starting with SSH:// on console application page
Adding Source :
adding source to application !
  • C:\ > git clone [copy the SSH:// URL here ]
  • This would initialize your application directory for Deploying.
  • Copy your Application Folders/Files with package.json and server.js [server.js name is mandatory to start your application ]
Changes in server.js:

Your Localhost is not equivalent to Cloud Setup so, you must provide ip and Port variable to run your application on cloud.And make sure port,ip should be same as Below for any type of Node.js 

var port = process.env.OPENSHIFT_NODEJS_PORT || 8080;
var ip = process.env.OPENSHIFT_NODEJS_IP || "";

and At last while making the application to listen to given port,ip


A sample of Server.js file :

Thats All just move in to your Directory through Command Prompt .execute three commands succesive manner and deploy your application.For updating application just follow these three commands one by one.

  • C:\ > git add .
  • C:\> git commit -am "initial commit"
  • C:\> git push origin master 
Debug & Logs :

  • just type  C:\> rhc tail <app_name>
will provide you ongoing Requests / Errors in the Node Applications .

Thus we have Successfully Deployed First Node.js Application on Openshift Hybrid Cloud.Openshift is Free to have Three application with Scalable Application , Https Connection access and also more add-ons With Limited three Gears each Application & 1 GB space.Have a try ! be cautious before adding Credit cards because it may cost you for overusage!.

Report for Error/Suggestions as Comments or mail me [email protected] / or connect with me in Facebook/Twitter.Enjoyed the Posts,Share is care and Do comments!


Post a Comment

feel free to post your comments! Don't Spam here!