mirror of
https://github.com/bigbluebutton/docker.git
synced 2024-11-25 17:43:11 +01:00
41 lines
1.1 KiB
Bash
Executable File
41 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Source:
|
|
# https://github.com/alangecker/bbb-packages/blob/f83431c227be2c95025ea81083baeaa87667b170/bbb-webrtc-sfu/data/etc/cron.hourly/bbb-restart-kms
|
|
|
|
#
|
|
# Restart Kurento every 24+ hours
|
|
#
|
|
|
|
if [ ! -f /tmp/bbb-kms-last-restart.txt ]; then
|
|
date +%Y-%m-%d\ %H:%M:%S > /tmp/bbb-kms-last-restart.txt
|
|
exit
|
|
fi
|
|
|
|
users=$(mongo --quiet mongodb://10.7.7.6:27017/meteor --eval "db.users.count({connectionStatus: 'online'})")
|
|
echo "currently active users: $users"
|
|
|
|
if [ "$users" -eq 0 ]; then
|
|
|
|
# Make sure 24 hours have passed since last restart
|
|
|
|
# Seconds since epoch for last restart
|
|
dt1=$(cat /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
|
|
echo "scheduled restart of kurento after 24h"
|
|
CONTAINER_ID=$(docker ps | grep kurento | awk '{print $1}')
|
|
docker restart $CONTAINER_ID
|
|
date +%Y-%m-%d\ %H:%M:%S > /tmp/bbb-kms-last-restart.txt
|
|
fi
|
|
fi
|