#!/bin/bash
#
# Usage: simply call:
#   ./launch_webapp
#
# To run in the background, call
#   ./launch_webapp -b
#
# To run sudo, call
#   ./launch_webapp -s
#
# To run both (as on a production server), call
#   ./launch_webapp -s -b
#
# To kill, find the PID corresponding to this process, and kill it
#
# Version: 2020mar14

run_background=0
run_sudo=
port=8188

while [ ! $# -eq 0 ]; do
    case "$1" in
        --background | -b) run_background=1;;
        --sudo | -s) run_sudo='sudo'; port=80;;
    esac
    shift
done

if [ $run_background -gt 0 ]; then
    echo "Running in background with sudo=$sudo and port=$port"
    $run_sudo nohup python3 ./cova_app.py $port 0 > voi_app.out &
else
    echo "Running verbose with sudo=$sudo and port=$port"
    $run_sudo python3 ./cova_app.py $port 1
fi
