[distcc] Re: Simple autodiscovery of distcc servers

Tobias Polzin polzin_spamprotect_ at gmx.de
Wed Aug 24 13:56:12 GMT 2005


Thank you for the explanation.

I have a shared directory, each 'node' puts in a file with its IP-address the
gcc-versions it supports (on different ports). If you want to compile, you can
grep in that directory for the used gcc-version and receive the IP-addresses and
ports. 

This worked well with linux 'nodes', but with Windows/Cygwin I had problems
because the startup process had permission problems and could not write to that
directory. But I believe this can be fixed.

Can you give me a hint, how you trigger an action (the sending of a message in
your case, deleting the file in mine) if the host goes down?

You mentioned that you might use the filtering. Though I believe that you are
capable of implementing the idea in your own way, I just want to post an update
that uses the process ID to make it more multi-user-environment-friendly.

Tobias

#
# Sorts DISTCC_HOSTS according to speed
#
# Usage "source distcc-hostsort"
#
# First Version: 17.01.05 (polzin_spamprotect_ at gmx dot de)
#
# $Id: distcc-hostsort,v 1.8 2005/08/24 13:37:52 tobias Exp $

tmplog=/tmp/dummy.$$.log
tmpfile=/tmp/dummy.$$.cpp

#subshell to preserve as much environment as possible
(
  cat > $tmpfile <<!
#include <iostream>
int main()
{
  std::cout << "hello distcc\n";
}
!

  oldhosts="$DISTCC_HOSTS"
  export TIMEFORMAT=%R
  rm -f $tmplog
  echo $oldhosts

  for host in $oldhosts
  do
     echo "$host" " start"
     ( DISTCC_HOSTS="$host";
       # using localhost is not wanted
       export DISTCC_FALLBACK=0
       t=` ( time   distcc gcc $tmpfile -c -o /dev/null) 2>&1 `
       echo -n $host " --- " $t
       # no floating point in scrips
       if [[ ${t%.*} -lt 6 ]];
       then
          echo $t $host >> $tmplog
          echo
       else
          echo " [too slow -> skipped]"
       fi
       )&
  done
  echo waiting for subtasks
  # jobs
  wait
)
echo ready
DISTCC_HOSTS=` sort -n $tmplog | awk '{ print $2; }' `
echo DISTCC_HOSTS=$DISTCC_HOSTS

count=` wc -l $tmplog | sed -e "s@$tmplog@@"`
MAKEFLAGS=`echo "$MAKEFLAGS" | sed -e "s/-j[0-9]*/-j$count/"`
echo MAKEFLAGS=$MAKEFLAGS

#clean up, as this file has to be sourced
rm -f $tmplog
rm -f $tmpfile
unset count
unset tmplog
unset tmpfile







More information about the distcc mailing list