#/usr/bin/bash
mode="engine"
debug="--debug"
#debug="--debug --verbose"


if [ -n "$1" ]; then
	if [[ $1 =~ ^(engine|lqs|api|api-prod)$ ]]; then 
  		mode=$1 
	fi
fi

echo "[ Run mode=$mode ]"

if [ $mode == "engine" ]; then
	/usr/bin/python3.7 aura.py
fi

if [ $mode == "lqs" ]; then
	(cd modules/liquidsoap/ && /usr/bin/liquidsoap $debug ./engine.liq) 
fi

if [ $mode == "api" ]; then
	echo "Building Web Applications"
	sh ./script/build-web.sh
	echo "Starting API Server"
	/usr/bin/python3.7 api.py
fi

if [ $mode == "api-prod" ]; then
	echo "Building Web Applications"
	sh ./script/build-web.sh
	echo "Starting API Server"
	gunicorn -c configuration/gunicorn.conf.py api:app
fi