Couldn't get a single command to work on WSL
no nodejs
so edited this from @ntshetty
#!/bin/bash
# ./monitor.sh main.py &
# $1 passes the filename
# source: @ntshetty stackoverflow.com/a/50284224/3426192
python $1 & # start
while true
do
mdhash1=`find $1 -type f -exec md5sum {} \; | sort -k 2 | md5sum`
sleep 5
mdhash2=`find $1 -type f -exec md5sum {} \; | sort -k 2 | md5sum`
if [ "$mdhash1" = "$mdhash2" ]; then
echo "Identical"
else
echo "Change Detected Restarting Web Server"
pkill -9 -f $1 # get PID to stop
python $1 & # restart
fi
done
echo "Ended"