Friday, July 6, 2012

how to install ql.io on EC2

For those who don't know what on earth is ql.io i strongly recommend you to read http://ql.io. In a nutshell is a software that allow queries on REST calls.
In term of architecture it is a pretty interesting piece to integrate if your company already have invested in developing its own REST API because:
- No refactoring is needed. ql.io consume your API as any other client, as a result, your API is still accessible as it is and ql.io just provide another way to consume it.
- Your API team can now focus on functionality rather than features.
- You can now provide at very low cost (no cost doesn't exist) a solid way to mash your services with others such as facebook, twatter or google maps.

This said, i still found the official documentation to be incredibly terrible (and containing mistakes) when it comes to installing the software and even worst when it comes down to doing it on EC2.


1. Creating the instance
I'm not going to do it, you're all big boyZ, you know the drill. However remember to open port 3000 on your security group. this said, let's move on the second step: installing nodejs.


2. Installing Nodejs.
As usual it's all in the doc https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager:

# sudo yum localinstall --nogpgcheck http://nodejs.tchol.org/repocfg/amzn1/nodejs-stable-release.noarch.rpm
# sudo yum install nodejs-compat-symlinks npm
# sudo yum install git

Nodejs and all it's dependances are installed.


3. Installing ql.io
This part is very tricky because there lies some mistake with the doc. You also have to install expat-dev as well as gcc and libssl. to do so, just type:

# sudo yum -y install expat-devel
# sudo yum -y install install gcc-c++ make
# sudo yum -y install openssl-devel


Then download the setup script:

# wget https://raw.github.com/ql-io/ql.io/master/modules/template/init.sh

Make it executable:

# chmod +x init.sh

Do not run it now, this script contain a mistake. We have to edit it and change the git command. Change the git address to https://github.com/ql-io/ql.io-template.git.


Once finished, you can create a new directory (wherever you want) and copy the new init.sh inside:

# mkdir myapp
# cd myapp
# cp ../location/of/init.sh ./


Now we can run it! Because certain module won't compile properly if the script is run as ec2-user, just sudo it:

# sudo ./init.sh

You can now go grab a drink or go to the toilets. Once you're back the install should be completed. You can now start the ql.io server by typing:

# sudo ./bin/start.sh

And play with it at http://<public_dns>:3000/console

Have fun