forked from extern/docker
periodic cleanup and kms restart
This commit is contained in:
parent
26c564a55e
commit
9349825c59
@ -135,6 +135,17 @@ services:
|
||||
networks:
|
||||
- bbb-net
|
||||
|
||||
periodic:
|
||||
build: mod/periodic
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
- mongodb
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
- bigbluebutton:/var/bigbluebutton
|
||||
networks:
|
||||
- bbb-net
|
||||
|
||||
volumes:
|
||||
bigbluebutton:
|
||||
|
||||
|
15
mod/periodic/Dockerfile
Normal file
15
mod/periodic/Dockerfile
Normal file
@ -0,0 +1,15 @@
|
||||
FROM debian:buster-slim
|
||||
|
||||
# -- install mongo cli
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y wget libcurl4 \
|
||||
&& wget https://repo.mongodb.org/apt/debian/dists/buster/mongodb-org/4.2/main/binary-amd64/mongodb-org-shell_4.2.6_amd64.deb \
|
||||
&& dpkg -i mongodb*.deb \
|
||||
&& rm mongodb*.deb
|
||||
|
||||
# -- install docker cli
|
||||
COPY --from=library/docker:latest /usr/local/bin/docker /usr/bin/docker
|
||||
|
||||
COPY bbb-restart-kms entrypoint.sh /
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
40
mod/periodic/bbb-restart-kms
Executable file
40
mod/periodic/bbb-restart-kms
Executable file
@ -0,0 +1,40 @@
|
||||
#!/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
|
17
mod/periodic/entrypoint.sh
Executable file
17
mod/periodic/entrypoint.sh
Executable file
@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
#
|
||||
# How N days back to keep files
|
||||
#
|
||||
history=5
|
||||
|
||||
while :
|
||||
do
|
||||
# restart kurento after 24h
|
||||
/bbb-restart-kms
|
||||
|
||||
# delete presentations older than N days
|
||||
find /var/bigbluebutton/ -maxdepth 1 -type d -name "*-*" -mtime +$history -exec rm -rf '{}' +
|
||||
|
||||
sleep 10s
|
||||
done
|
Loading…
Reference in New Issue
Block a user