Tags

, , ,

I’ve hosted an app in Openshift, and it was pretty interesting, mainly figuring out how to debug your application. I mean written code, deployed, hit the page. Ooops. 500 Error. Its working absolutely fine in my local.

You can explore web console to create application, add cartridges, and redeploy apps. But i’ll cover the commands, and my own way of doing 🙂

First Install RHC, The Command line interface for OpenShift.

gem install rhc
rhc setup # only for the first time, follow prompts, login to your openshift account

Then lets create an application. for instance i’m taking ‘blog’ as the application name.

rhc create-app blog python-2.6 # uses python cartridge and creates blog application

now lets add the database for our application.

rhc add-cartridge mongodb-2.4 --app blog

Interesting thing was, i’ve used mongo3.2.3 and written my app, but openshift gave only 2.4, so i had to migrate the code to fit to that version.

Now lets clone the repository to our machine, so that we can code 🙂

rhc git-clone blog
cd blog && git remote -v # To check the remote url

Cool, Now you can write code and push it. or if you want to push existing repository.

git remote add os ssh://url-of-openshift-application.com

and you can push the code. every push triggers the app deployment.
Main thing that was useful for debugging.
You can login to the machine, or tail the logs.

rhc ssh blog # logs in to machine
rhc tail -a blog # alternatively just look at logs

deployed your app 🙂

For reference, i’ve hosted my service bottle app, with mongodb.
https://github.com/dineshkumar-cse/PreferenceSyncService

I’ll go into details of wsgi.py which is used for deployment and mongodb connection in python app later.
 

Advertisements