#!/bin/bash
set -e
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT

filename=`realpath $1`

echo "Compiling MvS server"
cd state/mvs_server
python python_sccd_compiler/sccdc.py -p threads server.xml

echo "Starting MvS"
xterm -e "python run_mvs_server.py $filename || read -p \"Press any key to continue\"" &

echo "Waiting for boot-up"
sleep 1

echo "Compiling MvK server"
cd ../../kernel/mvk_server
python python_sccd_compiler/sccdc.py -p threads server.xml

echo "Starting MvK"
xterm -e "python run_mvk_server.py || read -p \"Press any key to continue\""
