Skip to content

Commit

Permalink
change from while loop to tail
Browse files Browse the repository at this point in the history
Co-authored-by: Carlos Martinez <[email protected]>
  • Loading branch information
Luatan and Dashboy1998 authored Feb 13, 2024
1 parent 024b051 commit aaae8c6
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions scripts/restore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,13 @@ if [ -f "$BACKUP_FILE" ]; then
exit 1
fi

while [ -n "$(pidof PalServer-Linux-Test)" ]
do
mapfile -t server_pids < <(pgrep PalServer-Linux-Test)
if [ "${#server_pids[@]}" -ne 0 ]; then
echo "Waiting for Palworld to exit.."
sleep 1
done
for pid in "${server_pids[@]}"; do
tail --pid="$pid" -f 2>/dev/null
done
fi
printf "\e[0;32mShutdown complete.\e[0m\n"

trap - ERR
Expand Down

0 comments on commit aaae8c6

Please sign in to comment.