added circuit breaker logic for frequent and repeated failures

This commit is contained in:
Sameer Naik 2015-09-30 23:08:15 +05:30
parent 5af7264173
commit 82f2eb0da9
2 changed files with 24 additions and 1 deletions

View File

@ -1 +0,0 @@
/bin/true

View File

@ -0,0 +1,21 @@
#!/usr/bin/with-contenv bash
failcount=0
if [ -f $BITNAMI_APP_DIR/tmp/failcount ]; then
failcount=$(cat $BITNAMI_APP_DIR/tmp/failcount)
fi
start=$(cat $BITNAMI_APP_DIR/tmp/start)
stop=`date '+%d%H%M%S'`
interval=`expr $stop - $start`
if test $interval -lt 30 ; then
failcount=`expr $failcount + 1`
else
failcount=0
fi
echo -n $failcount > $BITNAMI_APP_DIR/tmp/failcount
# bring down container on frequent failures. something is definitely wrong
if test $failcount -ge 3 ; then
s6-svscanctl -t /var/run/s6/services
fi

View File

@ -2,5 +2,8 @@
set -e
source $BITNAMI_PREFIX/bitnami-utils.sh
mkdir -p $BITNAMI_APP_DIR/tmp
date '+%d%H%M%S' > $BITNAMI_APP_DIR/tmp/start
rm -rf $BITNAMI_APP_VOL_PREFIX/data/mongod.lock
exec s6-setuidgid $BITNAMI_APP_USER mongod $PROGRAM_OPTIONS ${MONGODB_PASSWORD:+--auth} ${EXTRA_OPTIONS:+"$EXTRA_OPTIONS"}