detect failed unity launch and retry

This commit is contained in:
Cat Flynn 2021-03-09 17:30:48 +00:00
parent 091b078713
commit 131e8f8792
1 changed files with 33 additions and 11 deletions

View File

@ -12,28 +12,50 @@ echo "removing previous editor log..."
echo "starting build using unity v$unityversion..." echo "starting build using unity v$unityversion..."
# launch unity in batch mode unitypid=-1
open -g $editorpath --args \
-batchmode \ launch_unity () {
-quit \ # launch unity in batch mode
-nographics \ open -g $editorpath --args \
-developmentBuild \ -batchmode \
-executeMethod "Ktyl.Util.BuildCommand.Run" \ -quit \
-logFile $editorlogpath \ -nographics \
-projectPath "$(pwd)/game" -developmentBuild \
-executeMethod "Ktyl.Util.BuildCommand.Run" \
-logFile $editorlogpath \
-projectPath "$(pwd)/game"
unitypid=`pgrep -n Unity`
echo "launched unity ($pid)"
}
launch_unity
# wait for editor log to exist
tries=60 tries=60
count=0 count=0
while [ ! -f $editorlogpath ] while [ ! -f $editorlogpath ]
do do
if ps -p $unitypid > /dev/null
then
echo "unity ok ($unitypid)"
else
echo "unity is no longer running - trying again"
# reset launch attempts
count=0
launch_unity
continue
fi
# wait a second
sleep 1 sleep 1
# decrement # decrement
count=`expr $count + 1` count=`expr $count + 1`
if [ $count -eq $tries ] ; then if [ $count -eq $tries ] ; then
echo "early timeout - $tries seconds elapsed since launch attempt" echo "early timeout - $tries seconds elapsed since last launch attempt"
exit 1 exit 1
fi fi
done done