#!/bin/bash
### --- RUN SYSTEM DISPLAY MANAGER --- ###
i=0
cd $HOME/DisplaySystems
sleep 3
echo "DISP:     Running Display Manager - 1 of 3"
python3 registrationManager.py && python3 statusManager.py &
python3 fileManager.py --strict --remote 1>/dev/null 2>&1 && python3 -m uvicorn systemManager:app --host 0.0.0.0 --workers 1 1>/dev/null 2>&1 &
unclutter -idle 2 &
#
#
echo "DISP:     Verifying Display Manager Status - 2 of 3"
until curl -s -f -o /dev/null "http://localhost:8000/health"
do
    if [[ "$i" -eq 20 ]]; 
    then
        echo "DISP:     Fatal Error in Initilizing Data Manager ... "
    elif [[ "$i" -lt 20 ]]; 
    then
        let "++i"
    fi
    sleep 3
done
#
### --- RUN SYSTEM DATA MANAGER ---
echo "DISP:     Running Data Manager - 3 of 3"
python3 displayManager.py &
python3 dataManager.py