From aaae8c688ddb76ecb84fde5b045319fccb50bebd Mon Sep 17 00:00:00 2001 From: Luatan <74045606+Luatan@users.noreply.github.com> Date: Tue, 13 Feb 2024 09:01:26 +0100 Subject: [PATCH] change from while loop to tail Co-authored-by: Carlos Martinez --- scripts/restore.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/restore.sh b/scripts/restore.sh index c649951e5..207748fb3 100644 --- a/scripts/restore.sh +++ b/scripts/restore.sh @@ -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