Skip to content

Notes on legal server

Jaime J. Castrellon edited this page Jan 23, 2018 · 7 revisions

Keeping the server running

In order to keep the server up and running at all times, we added a file, /etc/init/nodeserver.conf, that looks like

start on net-device-up
stop on shutdown

respawn

setuid casereveal
chdir /home/casereveal/casereveal

exec nodejs server.js

If for some reason the server process dies, this will automatically respawn it.

However, there are times when you don't want this behavior (e.g., when testing from a different user account), so it can be stopped by

$ sudo initctl stop nodeserver

and resumed by

$ sudo initctl start nodeserver

Mapping ports

The node script listens on an internal port that is different than the default http port for web traffic. This port forwarding can be done with the iptables command. The relevant rule is

$ sudo iptables -L -t nat

Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination
REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:http redir ports <internal port>

where <internal port> is the port the server is listening on. There are plenty of instructions online for setting up this mapping.

Solution to BSON error running on local machine

Error: Cannot find module '../build/Release/bson' change line in the catch block of node_modules\mongodb\node_modules\bson\ext\index.js

Change: bson = require(‘../build/Release/bson’);

To: bson = require(‘../browser_build/bson’);

Solution to "zmq not installed" error running on local machine

Use homebrew to install zmq: brew install zmq