Following the work done for dreadnot, I’ll continue in the same vien and install another node application as a service.

So, this time we’re installing haibu from nodejitsu.

Why? It’s billed as a Platform-as-a-Service for node.js applications. While I don’t quite believe that, I like what it does anyways.

I’m assuming you have node installed based on instructions here. You will also need to have git installed.

Getting Started

I prefer to run haibu under it’s own user account, that way it will limit the amount of damage it can do if it’s compromised. It also should start when the system starts up, so we’ll create a upstart script for it since we’re running under Ubuntu.

User Account Creation

It’s pretty straight forward:

sudo groupadd haibu
sudo useradd -d /opt/haibu -c "haibu" -g haibu -m -r -s /bin/bash haibu
sudo passwd haibu

Remember the password you assign, you’ll need it for a little while.

We need to be able to log in to the account, so:

ssh haibu@localhost
mkdir apps
mkdir .ssh
touch .ssh/authorized_keys
chmod go-rwx .ssh/authorized_keys

Copy your public key into the authorized_keys file and you should be able to log in to the account with using the username and password

Installing Haibu

Really pretty easy:

sudo npm install -g haibu


Updated Again! You can create a config.json file that holds some configuration.

	"directories": {
		"apps": "/opt/haibu/h/apps",
		"autostart": "/opt/haibu/h/autostart",
		"packages": "/opt/haibu/h/packages"

You can find other parameters to adjust by doing a not-so-simple search:

 find . -name "*.js" -exec grep -i -H "haibu.config.get" {} \;

Run as a Service

On Ubuntu, you have to use upstart. Okay, maybe you don’t have to, but I prefer it.

sudo touch /etc/init/haibu.conf
sudo nano /etc/init/haibu.conf

Updated And copy the following:

start on runlevel [2345]

        exec sudo -u haibu /usr/bin/haibu --logger --advanced-replies
end script

To start it up:

sudo start haibu
sudo initctl list | grep haibu


05 April 2012