Merge pull request #91 from ChuckPa/chuckpa/new-start-stop

Change start/stop logic and timeout handling
This commit is contained in:
Chuck 2023-08-15 20:25:01 -04:00 committed by GitHub
commit 5d65e12a38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,12 +2,12 @@
######################################################################### #########################################################################
# Plex Media Server database check and repair utility script. # # Plex Media Server database check and repair utility script. #
# Maintainer: ChuckPa # # Maintainer: ChuckPa #
# Version: v1.0.10 # # Version: v1.0.11 #
# Date: 30-Jul-2023 # # Date: 15-Aug-2023 #
######################################################################### #########################################################################
# Version for display purposes # Version for display purposes
Version="v1.0.10" Version="v1.0.11"
# Flag when temp files are to be retained # Flag when temp files are to be retained
Retain=0 Retain=0
@ -1383,22 +1383,35 @@ DoStop(){
return 1 return 1
else else
if IsRunning; then
Output "Stopping PMS." Output "Stopping PMS."
else
Output "PMS already stopped."
return 0
fi
$StopCommand > /dev/null 2> /dev/null $StopCommand > /dev/null 2> /dev/null
Result=$? Result=$?
if [ $Result -ne 0 ]; then
Output "Cannot send stop command to PMS, error $Result. Please stop manually."
WriteLog "Cannot send stop command to PMS, error $Result. Please stop manually."
return 1
fi
Count=10 Count=10
while [ $Result -eq 0 ] && IsRunning && [ $Count -gt 0 ] while IsRunning && [ $Count -gt 0 ]
do do
sleep 1 sleep 3
Count=$((Count - 1)) Count=$((Count - 1))
done done
if [ $Result -eq 0 ]; then if ! IsRunning; then
WriteLog "Stop - PASS" WriteLog "Stop - PASS"
Output "Stopped PMS." Output "Stopped PMS."
return 0
else else
WriteLog "Stop - FAIL ($Result)" WriteLog "Stop - FAIL (Timeout)"
Output "Could not stop PMS. Error code: $Result" Output "Could not stop PMS. PMS did not shutdown within 30 second limit."
fi fi
fi fi
return $Result return $Result