# HG changeset patch # User Henry S. Thompson # Date 1538477565 0 # Node ID 55e953e5c66f9bd6a1b2f690a3b7e61af97b9946 # Parent 5db6015689a23bcc5e9f37c80f4576c1cc817b5b wrun.sh, invoke.sh: add control of use of nohup, with -i(mmediately) and -w(ait) respectively wrun.sh: add support for fixed file input via -ff, handle -ff - in obvious way wbash.sh: use -ff - and -i to execute shell commands on all workers diff -r 5db6015689a2 -r 55e953e5c66f master/bin/internal/invoke.sh --- a/master/bin/internal/invoke.sh Mon Oct 01 18:29:39 2018 +0000 +++ b/master/bin/internal/invoke.sh Tue Oct 02 10:52:45 2018 +0000 @@ -6,6 +6,11 @@ # via ssh to ip:port # If ifile is not /dev/null, feed in as stdin # Unless -x, worker id is passed as first arg +if [ "$1" = "-w" ] +then + shift + wait=1 +fi if [ "$1" = "-x" ] then shift @@ -24,7 +29,10 @@ if [ "$ifile" != "/dev/null" ] then echo "# from $ifile" 1>&2 - scp -P $port $ifile $ip:ifile.txt && \ + scp -P $port $ifile $ip:ifile.txt +fi || echo scp failed, status=$? 1>&2 +if [ "$wait" ] +then ssh -t -p $port $ip "nohup $cmd $id $me ""$@"" > nohup.cc" else ssh -p $port $ip "$cmd $id $me ""$@" diff -r 5db6015689a2 -r 55e953e5c66f master/bin/wbash.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/master/bin/wbash.sh Tue Oct 02 10:52:45 2018 +0000 @@ -0,0 +1,17 @@ +#!/bin/bash +if [ $# -lt 1 ] +then + cat 1>&2 <&2 <&2 me=$(az vm list-ip-addresses -g cc -n Deb1 | jq -r '.[0].virtualMachine.network.publicIpAddresses|.[0].ipAddress') echo me=$me 1>&2 +wait='-w' if [ "$1" = "-f" ] then file=$2 shift 2 tfile=$(mktemp) split -n r/$np -u --filter="cat > $tfile\$\$" $file & - # Wait for fifos to be built + # Wait for files to be built while [ $np -gt $(ls ${tfile}* | wc -l) ]; do echo -n . 1>&2; sleep 1; done echo 1>&2 wc -l ${tfile}* 1>&2 +elif [ "$1" = "-ff" ] +then + file=$2 + shift 2 + if [ "$file" = "-" ] + then + file=$(mktemp) + cat > $file + fi else file=/dev/null + wait='' fi -echo "|$np|$file|$tfile|" 1>&2 +if [ "$1" = "-i" ] +then + shift + wait='' +fi +echo "|$np|$file|$tfile|$wait|" 1>&2 paste -d ' ' \ - <(if [ "$file" = "/dev/null" ] - then yes /dev/null|head -$np + <(if [ -z "$tfile" ] + then yes $file|head -$np else echo ${tfile}?* | tr ' ' '\012' # the name of the file of # input lines for each worker @@ -64,5 +83,5 @@ do echo $i $port $ip done) | \ - parallel --gnu --colsep ' ' -j $np "$(dirname "$0")"/internal/invoke.sh $id $me "$cmd" {} "$@" || { r=$? ; echo parallel exited with status=$r 1>&2;} + parallel --gnu --colsep ' ' -j $np "$(dirname "$0")"/internal/invoke.sh $wait $id $me "$cmd" {} "$@" || { r=$? ; echo parallel exited with status=$r 1>&2;} if [ "${tfile}" ]; then rm ${tfile}*; fi