Skip to content

Commit 719465d

Browse files
task: wait on pid before graceful shutdown is complete (#2076)
* task: wait on pid before graceful shutdown is complete
1 parent 73f6068 commit 719465d

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

resources/graceful_shutdown.sh

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,16 @@ function printError {
5353
echo "$@" 1>&2
5454
}
5555

56+
function waitForPid {
57+
while [ -d /proc/$1 ] ;do
58+
echo "PID $1 still exists"
59+
sleep 10
60+
done
61+
echo "PID $1 is done"
62+
}
63+
64+
JVB_PID=$(ps aux | grep java | grep jitsi-videobridge.jar | awk '{print $2}')
65+
5666
shutdownStatus=`curl -s -o /dev/null -H "Content-Type: application/json" -d '{ "graceful-shutdown": "true" }' -w "%{http_code}" "$hostUrl/colibri/shutdown"`
5767
if [ "$shutdownStatus" == "200" ]
5868
then
@@ -63,13 +73,14 @@ then
6373
sleep 10
6474
participantCount=`getParticipantCount`
6575
if [[ $? -gt 0 ]] ; then
66-
printInfo "Failed to get participant count, Bridge already shutdown"
76+
printInfo "Failed to get participant count, bridge may be already shutdown, waiting on pid $JVB_PID"
77+
waitForPid $JVB_PID
6778
exit 0
6879
fi
6980
done
7081

71-
echo "Waiting 60 seconds for bridge to finish shutting down"
72-
sleep 60
82+
echo "Waiting for bridge pid $JVB_PID to finish shutting down"
83+
waitForPid $JVB_PID
7384
printInfo "Bridge shutdown OK"
7485
exit 0
7586
else

0 commit comments

Comments
 (0)