Skip to content

Install a own Fishtris Server

Sven Anders edited this page Mar 21, 2014 · 5 revisions

Install node.js

https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager

Install npm

curl https://www.npmjs.org/install.sh >install.sh
chmod 755 install.sh
./install.sh

Install socket.io

npm install -p socket.io
npm install  winston

Start the Fishtris Server

useradd fishtris
su -s /bin/bash fishtris
git clone [email protected]:tabacha/fishtris2.git
cd fishtris2
nodejs fishtris-server.js

Now you can connect with a browser to http://localhost:8080/

Production enviroment

Do not start fishtris-server as root. This is not good, for security reasons.

If you want to listen to port 80 add as root:

iptables -t nat -A PREROUTING -i eth0 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080

If you want Ipv6, there is no nat rule. We use haproxy for translating between port 80 and port 8080. You find the required config file in git doc/haproxy.cfg

Not required, but usefull

Install js-beatuify

npm install -p js-beatuify

Install jshint

npm install jshint -g

Install uglify-js -g

npm install uglify-js -g

Create a pre-comit check

#!/bin/bash
JSB=$(which js-beautify)

if [ -z "$JSB" ] ; then
   echo please install js-beautify
   exit 1
else 
     $JSB fishtris.js >/tmp/fishtris$$.js
     diff fishtris.js /tmp/fishtris$$.js
     if [ $? != 0 ] ; then 
        echo "Please js-beautify -r fishtris.js"
        exit 1
     fi

     $JSB fishtris-server.js >/tmp/fishtris-server$$.js
     diff fishtris-server.js /tmp/fishtris-server$$.js
     if [ $? != 0 ] ; then 
        echo "Please js-beautify -r fishtris-server.js"
        exit 1
     fi

     rm /tmp/fishtris$$.js /tmp/fishtris-server$$.js

fi
exit 0