From a2444037d327d6619ad7426bc9c658875bbb64c0 Mon Sep 17 00:00:00 2001 From: Koen Kooi Date: Fri, 7 Jan 2011 10:17:45 +0000 Subject: [PATCH] Narcissus: throttle package install when the load is too high Signed-off-by: Koen Kooi --- scripts/install-package.sh | 3 +++ scripts/sleep.sh | 10 ++++++++++ 2 files changed, 13 insertions(+) create mode 100644 scripts/sleep.sh diff --git a/scripts/install-package.sh b/scripts/install-package.sh index 6753388..9cc7406 100755 --- a/scripts/install-package.sh +++ b/scripts/install-package.sh @@ -32,6 +32,9 @@ echo $packagelist > ${TARGET_DIR}.txt echo "installing $packagelist" for pkg in $packagelist ; do + # Sleep N seconds when the load on the buildserver is too high + sh ${PWD}scripts/sleep.sh + echo "running: opkg-cl ${CACHE} -o ${TARGET_DIR} -f ${TARGET_DIR}/etc/opkg.conf -t ${OPKG_TMP_DIR} install $pkg" yes | bin/opkg-cl ${CACHE} -o ${TARGET_DIR} -f ${TARGET_DIR}/etc/opkg.conf -t ${OPKG_TMP_DIR} install $pkg | tee ${TARGET_DIR}/log.txt grep -e "rror oc" -e "ollected er" ${TARGET_DIR}/log.txt diff --git a/scripts/sleep.sh b/scripts/sleep.sh new file mode 100644 index 0000000..15a07de --- /dev/null +++ b/scripts/sleep.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +LOAD="$(cat /proc/loadavg | awk -F. '{print $1}')" + +if [ $LOAD -gt 10 ] ; then + echo "load to high: $LOAD, sleeping" + sleep 10 +else + echo "load acceptable: $LOAD, continuing" +fi