b96d549d29
Fixes #11418 The `connectionStatus` property was removed from the Users collection in 2.3, so the check was always returning 0 which means the cron job could potentially restart KMS and SFU while there were still active users.
36 lines
801 B
Bash
36 lines
801 B
Bash
#!/bin/bash
|
|
|
|
#
|
|
# Restart Kurento every 24+ hours
|
|
#
|
|
|
|
if [ ! -f /var/tmp/bbb-kms-last-restart.txt ]; then
|
|
date +%Y-%m-%d\ %H:%M:%S > /var/tmp/bbb-kms-last-restart.txt
|
|
exit
|
|
fi
|
|
|
|
users=$(mongo --quiet mongodb://127.0.1.1:27017/meteor --eval "db.users.count()")
|
|
|
|
if [ "$users" -eq 0 ]; then
|
|
|
|
# Make sure 24 hours have passed since last restart
|
|
|
|
# Seconds since epoch for last restart
|
|
dt1=$(cat /var/tmp/bbb-kms-last-restart.txt)
|
|
t1=`date --date="$dt1" +%s`
|
|
|
|
# Current seconds since epoch
|
|
dt2=`date +%Y-%m-%d\ %H:%M:%S`
|
|
t2=`date --date="$dt2" +%s`
|
|
|
|
# Hours since last restart
|
|
let "tDiff=$t2-$t1"
|
|
let "hDiff=$tDiff/3600"
|
|
|
|
if [ "$hDiff" -ge 24 ]; then
|
|
systemctl restart kurento-media-server bbb-webrtc-sfu
|
|
date +%Y-%m-%d\ %H:%M:%S > /var/tmp/bbb-kms-last-restart.txt
|
|
fi
|
|
fi
|
|
|