#!/bin/bash

WD="."
if [ "$1" == "-d" ]; then
	WD=${2:-.}
	shift 2
fi
WD=`realpath "${WD}"`

cd $WD || exit 1
export NODE_PATH="${WD}:${NODE_PATH}"
rm -f app.stop
while [ ! -f app.stop ]; do
	node --trace-deprecation app.js $* >> logs/console.log 2>&1
	[ $? -eq 127 ] && break;
	sleep 5
done

exit 0
