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 /sitesummary-client | |
| 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.
Diffstat (limited to 'sitesummary-client')
| -rw-r--r-- | sitesummary-client | 15 |
1 files changed, 15 insertions, 0 deletions
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 |
