Friday Aug 18, 2006
Friday Aug 18, 2006
cat Mersenne.ksh
#!/bin/ksh
#$ -N Mersenne
#$ -cwd
# Set the environment variables
if [ -f $HOME/.profile ]; then
. $HOME/.profile
fi
numClients=5
echo "Starting the server..."
svrResp=$(qsub -N server startServers.ksh)
echo svrResp is $svrResp
svrJobId=$(echo "$svrResp" | awk '{print $3}')
echo svrJobId is $svrJobId
# Wait until the server is started
status="not running"
until [ "$status" == "r" ]
do
status=$( qstat | nawk '/'$svrJobId'/ {print $5}' )
echo Server job status is $status
sleep 10
done
#Wait until the serverhost file is created
filename="$HOME/serverhost"
until test -f $filename
do
sleep 10
done
# then pull the server node name from the file
servernode=$(cat $filename)
rm $filename
echo "Server is running on" $servernode "Submitting a set of clients to the grid for remote execution..."
qsub -N clients -t 1-$numClients startClient.ksh $servernode
echo "Submitting a cleanup job that will wait until the clients are complete"
qsub -hold_jid clients cleanup.ksh $svrJobId
cat startServers.ksh #!/bin/ksh #$ -N startServers #$ -cwd echo "Starting the registry in the background..." rmiregistry & # Wait until the registry is started proc=0 while [ "$proc" == 0 ] do proc=$( ps -ef | grep "[r]miregistry" ) echo $proc is running sleep 10 done # Place the name of this host in a file, so that clients can read it hostname > $HOME/serverhost echo "The servers location is" $(hostname) echo "Starting the server..." java MersenneServerImpl
cat startClient.ksh #!/bin/ksh #$ -N startClient #$ -cwd servernode=$1 echo "Starting a client on $(hostname) to talk to server running on" $servernode java MersenneClient $servernode
cat cleanup.ksh #!/bin/ksh #$ -N cleanup #$ -cwd # Set the environment variables if [ -f $HOME/.profile ]; then . $HOME/.profile fi echo Killing the server, job number $1 ... qdel $1