Wildfly CLI on OpenShift

SSH into server using ‘rhc ssh appname’, then:

jboss-cli.sh -c --controller=$OPENSHIFT_WILDFLY_IP:$OPENSHIFT_WILDFLY_MANAGEMENT_HTTP_PORT

Then you can cd to the service that you want to inspect, eg:

cd /subsystem=messaging/hornetq-server=default/jms-queue=exampleQueue

and from there, ls will list all the properties available.

More info here and here.

Another server drive failure – so migrated my WordPress blog to OpenShift

So it happened. Again. Although the last time was at least 5 years ago. A ton of i/o errors in syslog, and one of my drives in a RAID1 array is not responding. Strangely the other drive although still working is reporting in SMART that it is also about to die. That seems unlikely to have two drives go at the same time?

SMART overall-health self-assessment test result: FAILED!
Drive failure expected in less than 24 hours. SAVE ALL DATA.

Uh-oh.

So here’s the deal. The last time, roughly 5 years ago, I had a drive completely die and my Ubuntu server than I run from home wouldn’t boot. I lost several months of blog posts and notes. When I rebuilt it, I installed a pair of 250GB Hitachi Deskstar P7K500 drives in RAID1 configuration. The odd thing is that one of the drives kept dropping out of the array every few months in the last year, but it could be added back with the mdadm commands so I didn’t think much of it. Maybe I should have looked more closely in the logs what was going on.

So I’m at the decision point. Probably shouldn’t just replace one of the drives if one is alreay bad, should probably replace them both. Do I want to spend a couple of hundred on another pair of drives? At least the RAID array probably saved me from completely losing everything again.

I’ve run my own Linux server from home since about 2000. It’s physically changed motherboards a couple of times, its been a PIII and most recently a P4 with just 512MB of RAM and I’ve run JBoss versions from 3.x or so upto 5.x, Glassfish 3.x, I’ve run my blog on on my own custom app (BBWeblog), then Drupal, Joomla, and most recently WordPress on Apache. I’ve enjoyed running my own server since it means I can do whatever I like with it, and other than the cost for the hardware, there’s no hosting costs for my sites.

I think it’s reached the point though where enough is enough. Time to move online somewhere. Given that I’ve been using OpenShift for a number of projects at work, it seemed an easy choice to spin up a gear using the WordPress template and just import my site. And it only took a couple of minutes to get it up and running. I spent more time playing around with the WordPress Themes than I did actually setting it up and importing my site.

The only slightly tricky part was to update the DNS entry to point to OpenShift, which involved the following steps:

  • Update my record on zoneedit.com to delete the entry for my domain. I’ve been using ZoneEdit because they support Dynamic IP addresses by giving you a script to run locally to update what your actual IP address is periodically.
  • Update my GoDaddy account to remove the ZoneEdit DNS servers, switch from Custom DNS settings to Standard, click on DNS Zone File, and then add a CNAME record for ‘www’ pointing to my apps’s URL on OpenShift
  • Back to OpenShift, run ‘rhc add-alias wordpress www.kevinhooke.com’ where wordpress is the name of my app.

This post was useful, and here’s the docs for ‘rhc add-alias’

Done! It actually only took a couple of minutes for the changes to get reflected too, i.e. if I ping www.kevinhooke.com it’s now picking up the new IP for my OpenShift server on AWS.

I’m probably still going to play around with some customization options on WordPress, but  from start to finish it was probably less than an hour. It would have taken me far much longer than that to install new drives in my server, reinstall from a drive image, and get it all set up again. So, fingers crossed, here’s looking forward to my new home on OpenShift 🙂

Merging a new OpenShift project git repo with an existing local project repo

Steps mainly from here, assuming you already have a local git repo for an existing project and you want to merge it into a newly created project on OpenShift for deployment:

Add the remote openshift remote:

git remote add openshift_git_repo_url

Merge the content from the newly created repo into your existing project (this will be some pom.xml changes and the .openshift directory for remote server settings and triggers etc):

git merge openshift/master -s recursive -X ours

This didn’t do anything for me, it said ‘already up to date’, so I pulled down the files from the remote with:

git pull openshift master

which resulted in a couple of conflicts, like pom.xml. Update the files with conflicts to resolve them and commit the changes, then push back to the remote:

git push openshift master

Done!

Adding jars to your OpenShift remote Maven repo

If your OpenShift app has dependencies on other Jars that are not publicly available in the usual maven repos (for example, other Jars from your own projects), you can push them to your remote Maven repo used when your app builds remotely.

Commit the jar in the root of your OpenShift project.

Edit .openshift/action_hooks/pre_build and add the following, updating Jar name etc:

mvn install:install-file --debug -Dfile=../../YourProjectName/runtime/repo/YourJarName.jar
  -DgeneratePom=true -DartifactId=YourArtifactName -Dversion=0.0.1-SNAPSHOT
  -DgroupId=your.group.id -Dpackaging=jar

Commit your changes and push to OpenShift – the jar will get installed to your remote repo, and now you can add a Maven dependency against it in your project’s pom.xml.