Monday, September 14, 2015

I have recently moved my personal website from Google App Engine to OpenShift. I was looking at the list backend technologies supported by OpenShift and HHVM piqued my interest. I remembered how Facebook introduced a new language a few years ago and I never tried it out. So I decided to give it a try now. Fortunately, there is an OpenShift quickstart available for HHVM and we don't need to do any complex configuration to set it up.

First of all, you need to sign up for OpenShift (it's free!). Now, that you have an OpenShift account, go ahead and create a new application. You will be shown a list of popular cartridges and quickstarts available. Select the HHVM quickstart. The next page will ask more details about your application like the sub-domain name, scaling options etc. Fill in the details as you wish and create the application.

Now that your application is ready, you need a way to make changes to it. For that, you need to install rhc (OpenShift client tools) and manage your source code with git. Please refer to OpenShift's help section for a detailed explanation.

At this point, I faced a problem. I added some Hack code and pushed to the server. To my surprise, it didn't work as expected. In fact, the page displayed nothing! On the contrary, PHP code worked fine. So, I logged into the application gear and examined the HHVM log file. The following error was being thrown:

Hack typechecking failed: typechecker command not found

For some reason, the typechecker command hh_client is unavailable in the current path. I wasn't able to figure out why this was so but I figured out a workaround for this problem. We can fix it by disabling automatic typechecking. Add the following line to config/hhvm.d/config.ini.erb in your application code repository:

hhvm.hack.lang.auto_typecheck = false

This will disable automatic typechecking which means that before pushing your code to the server, it is advisable to run typechecking on your local machine.

Follow by Email

Blog moved here!

This blog was at http://theanirudhrb.wordpress.com/ before. The WordPress blog will no longer be updated and will be removed soon. I will try to get the old posts here. (It's not very easy to edit all that \( \LaTeX \) that is there!)