Mercurial > hg > cc > azure
changeset 54:1099246f22b6
new scripts
author | Henry S. Thompson <ht@markup.co.uk> |
---|---|
date | Fri, 08 Feb 2019 17:46:49 +0000 |
parents | 9df880d45440 |
children | c49b169339b1 |
files | master/bin/bindWorkerVars.sh master/bin/pbash.sh master/bin/wakeWorker.sh |
diffstat | 3 files changed, 64 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/master/bin/bindWorkerVars.sh Fri Feb 08 17:46:49 2019 +0000 @@ -0,0 +1,16 @@ +# Usage . bindWorkerVars.sh name +# (Re)init worker environment vars +name=$1 +f=$HOME/.parallel/$name +rm -f $f +az vmss list-instance-connection-info -g cc -n $name | tr -s ',": ' '\t' | \ + tail -n +2 | fgrep instance |cut -f 4,5 | \ + while read ip port + do + echo ssh -p $port $ip >> $f + done +ip=$(head -1 $f | cut -f 4 -d ' ') +export $name=$ip +export WORKERS=$name +sed '/export WORKERS/s/=.*$/='$name'/;/WORKERS names/s/ .*=[^ ]* / '$name'='$ip' /' -i $HOME/.bashrc +echo $name=$ip
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/master/bin/pbash.sh Fri Feb 08 17:46:49 2019 +0000 @@ -0,0 +1,41 @@ +#!/bin/bash +if [ $# -lt 1 ] +then + cat 1>&2 <<EOF +Usage: $0 [-h sshHostFile] cmd [...args] +Where SSname is the name of a VM scale set. +sshHostFile (defaults to $WORKERS) is the name of a file in + .parallel which lists hosts and ports, see man parallel for details + +Runs cmds/cmdlines on every machine in a scale set, + using parallel --nonall + +cmd+args can be quoted to run over multiple lines + +Use xargs $0... to get multiple args from stdin, e.g. +> xargs $0 W4 echo +hello +world +^D +hello world +hello world +... + +Do + > echo 'will cite' | parallel --citation 2>/dev/null +to turn off citation prompt +EOF + exit 1 +fi +if [ $1 = -h ] +then + shift + shf="$1" + shift +else + shf=$WORKERS +fi +parallel --sshloginfile $shf --nonall "$@" + + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/master/bin/wakeWorker.sh Fri Feb 08 17:46:49 2019 +0000 @@ -0,0 +1,7 @@ +# Usage . wakeWorker.sh name +# Resurrect a worker cluster that was deallocated +set -e -o pipefail +name=$1 +echo restarting... +az vmss restart -g cc -n $name +. bindWorkerVars.sh $name