Project

General

Profile

Support #353

Setting Up A Self-Hosted HabitRPG Node

Added by Daniel Curtis over 10 years ago. Updated almost 10 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
-
Target version:
-
Start date:
03/31/2014
Due date:
% Done:

100%

Estimated time:
3.00 h
Spent time:

Description

This guide is to document setting up a self-hosted HabitRPG node. It is assumed that the node is setup and configured as an ISPConfig web server node, as covered in Issue #177.

Install and set up MongoDB

apt-get install mongodb

Install and set up NodeJS and NPM

Because Ubuntu's software repositories may run a few months behind the latest revisions, Ubuntu users will want to install node from an updated repository:

apt-get update
apt-get install python-software-properties
apt-add-repository ppa:chris-lea/node.js
apt-get update
apt-get install nodejs

(Optional) Building NodeJS from source

Since I am not running an Ubuntu system, I had to resort to compiling the latest NodeJS from source.

Resolve prerequisite packages

apt-get install python g++ make checkinstall

Make, then change into a temporary build folder

src=$(mktemp -d) && cd $src

Get latest NodeJS source

wget -N http://nodejs.org/dist/node-latest.tar.gz

Extract NodeJS source

tar xzvf node-latest.tar.gz && cd node-v*

Configure build variables

./configure

Build a .deb package

fakeroot checkinstall -y --install=no --pkgversion $(echo $(pwd) | sed -n -re's/.+node-v(.+)$/\1/p') make -j$(($(nproc)+1)) install
  • Install the NodeJS .deb
    sudo dpkg -i node_*
    

Install and set up Git

Fork the repository on your computer

git clone https://github.com/HabitRPG/habitrpg.git

Make sure you are on the develop branch where all the development, this should be the default branch if you are forking from github. You can check with git branch, the branch with a star next to it is the branch you are currently on. If you are not on the develop branch switch to it

cd /path/to/habitrpg
git checkout develop

Install grunt-cli npm package globally

Note: On some systems you may need to add sudo in front of this command

npm install -g grunt-cli bower

Install the npm and bower packages:

npm install

Create a config file from the example one:

cp config.json.example config.json
Edit config.json with your values for:
  • ADMIN_EMAIL
  • SMTP_USER
  • SMTP_PASS
  • SMTP_SERVICE

Ensure that Mongo is running:

service mongodb start

Then seed the database with initial settings:

node ./src/seed.js

Run HabitRPG

There are two ways to start the web application:
  1. Using grunt
    grunt run:dev
    
  2. OR Using NPM
    npm start
    

Autostart HabitRPG at boot time

I wanted to have HabitRPG start at boot, and unfortunately there wasn't any documentation on how to do this. Nevertheless, I found that adding the following line to /etc/rc.local started the server at boot time:

cd /usr/local/habitrpg && npm start &

This will start an HTTP server on port 3000, so pointing a web browser there will access the HabitRPG site

Troubleshooting

I encountered a couple of errors while starting the web application.

Failure to start grunt

failed to locate @import file ../bower_components/angular-loading-bar/build/loading-bar.css Warning: Stylus failed to compile. Used --force, continuing.

You need to update bower and restart the command:

bower update
grunt run:dev

bower update fails

Error: EEXIST, rename '.bower-cache/ef2188def21eb1bbd1f1792311942a53/1.2.15-build.2360%2Bsha.6b18a56'

If you encounter this or a similar error when issuing a bower update, perform the following:

cd .bower-cache/ef2188def21eb1bbd1f1792311942a53/
rm -rf 1.2.15-build.2360%2Bsha.6b18a56

The actual names of these directories may differ on your system.

Resources


Related issues

Copied to FreeBSD Administration - Support #565: Install -HabitRPG- Habitica on FreeBSDClosedDaniel Curtis03/31/2014

Actions

Also available in: Atom PDF