OSGi on OpenShift (Free, OpenSource Cloud)

OpenShift is Red Hat's cloud. You can create and use cloud instances for free, for development purposes - a free cloud playground!!
OpenShift comes with a number of cartridges, including a somewhat reduced version of JBoss AS7 (no OSGi), Node.js and Jenkins. However OpenShift also has a DIY application type. With this you can deploy whatever you like :) So, I took the Felix OSGi framework and deployed that in OpenShift using the DIY type!

Here's what I did.
1. Get a free OpenShift account by signing up at http://openshift.redhat.com
2. Once you have your account you can create an application:

5. At this point you can start putting your cloud content into git. Initially your clone contains a README, some mostly empty directories and some openshift hooks:

$ ls -a

.git README misc.openshift diy

So what next?
I started by adding a modified Apache Felix installation to a directory called osgi/felix-framework-4.0.2. I took Felix 4.0.2 and instead of the gogo terminal-based console bundles I used the Web Console with Config Admin and Pax-Web.

First the current directory is changed to where Felix is stored, and then Felix is launched with as extra option for Pax Web, the IP address that OpenShift wants us to use. The port number is configured as 8080, as required by OpenShift, this is specified in the Felix configuration file.

That's pretty much it - I also created a fairly blunt stop script that kills all the Java processed. I guess that could be refined ;)

Ok, so let's try it out.
As a convenience I added this setup as a github project called felix-openshift, you can get it into your freshly cloned OpenShift repo with:

Then merge the content in with:$ git merge -Xtheirs FETCH_HEAD
Note that -Xtheirs automatically takes the start and stop scripts from the fetched project and overwrites the local ones. If your git client doesn't support this option you'll probably have to merge these scripts by hand...