diff options
author | Petter Reinholdtsen <pere@hungry.com> | 2007-07-02 22:51:46 +0000 |
---|---|---|
committer | Petter Reinholdtsen <pere@hungry.com> | 2007-07-02 22:51:46 +0000 |
commit | 178079b26776121f68fcef4067648a9c90d264b9 (patch) | |
tree | 26e953e3b4eb6a5d00d7222c47a0fcf9e4cf1c0f | |
parent | 3a2d5fe94fdc86a7f764a94d4f76fad689888756 (diff) | |
download | sitesummary-178079b26776121f68fcef4067648a9c90d264b9.tar.gz sitesummary-178079b26776121f68fcef4067648a9c90d264b9.tar.bz2 sitesummary-178079b26776121f68fcef4067648a9c90d264b9.tar.xz |
Modify the client code to sleep for a random number of seconds
between 0 and 3600 to make sure all clients do not overload the
server.
-rw-r--r-- | debian/changelog | 8 | ||||
-rw-r--r-- | sitesummary-client | 15 |
2 files changed, 23 insertions, 0 deletions
diff --git a/debian/changelog b/debian/changelog index 246eb4a..d5b3f3b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +sitesummary (0.0.27) UNRELEASED; urgency=low + + * Modify the client code to sleep for a random number of seconds + between 0 and 3600 to make sure all clients do not overload the + server. + + -- Petter Reinholdtsen <pere@debian.org> Tue, 3 Jul 2007 00:49:14 +0200 + sitesummary (0.0.26) unstable; urgency=low * Add code in the server cronjob to generate a replacement diff --git a/sitesummary-client b/sitesummary-client index 9e53e1f..44e416b 100644 --- a/sitesummary-client +++ b/sitesummary-client @@ -53,6 +53,21 @@ do done done +# Sleep a random number of seconds to avoid all clients connecting to +# the server at the same time. Based on code from the cron-apt +# package. +if [ -n "$runsleep" ] ; then + if [ $runsleep -gt 0 ] ; then + if [ -z "$RANDOM" ] ; then + # A fix for shells that do not have this bash feature. + RANDOM=$(dd if=/dev/urandom count=1 2> /dev/null | cksum | cut -c"1-5") + fi + TIME=$(($RANDOM % $runsleep)) + sleep $TIME + fi +fi + + mkdir $tmpdir && cd $tmpdir for fragdir in $fragdirs ; do |