~ubuntu-branches/ubuntu/vivid/cctools/vivid

« back to all changes in this revision

Viewing changes to dttools/src/sge_submit_workers

  • Committer: Bazaar Package Importer
  • Author(s): Michael Hanke
  • Date: 2011-05-07 09:05:00 UTC
  • Revision ID: james.westby@ubuntu.com-20110507090500-lqpmdtwndor6e7os
Tags: upstream-3.3.2
ImportĀ upstreamĀ versionĀ 3.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
show_help() 
 
4
{
 
5
        echo "Use: sge_submit_workers [options] <servername> <port> <num-workers>"
 
6
        echo "options:"
 
7
        echo "  -a               Enable auto mode."
 
8
        echo "  -s               Run as a shared worker."
 
9
        echo "  -N <name>        Preferred master name."
 
10
        echo "  -C <catalog>     Set catalog server to <catalog>. <catalog> format: HOSTNAME:PORT."
 
11
        echo "  -t <time>        Abort after this amount of idle time. (default=900s)"
 
12
        echo "  -p <parameters>  SGE qsub parameters."
 
13
        echo "  -h               Show this help message."
 
14
        exit 1
 
15
}
 
16
 
 
17
arguments=""
 
18
use_auto=0
 
19
parameters=""
 
20
 
 
21
while getopts asN:t:p:h opt 
 
22
do
 
23
        case "$opt" in
 
24
                a)  arguments="$arguments -a"; use_auto=1;;
 
25
                s)  arguments="$arguments -s";;
 
26
                N)  arguments="$arguments -N $OPTARG";;
 
27
                C)  arguments="$arguments -C $OPTARG";;
 
28
                t)  arguments="$arguments -t $OPTARG";;
 
29
                p)  parameters="$parameters $OPTARG";;
 
30
                h)  show_help;;
 
31
                \?) show_help;;
 
32
        esac
 
33
done
 
34
 
 
35
shift $(expr $OPTIND - 1)
 
36
 
 
37
if [ $use_auto = 0 ]; then
 
38
    if [ X$3 = X ]
 
39
    then
 
40
        show_help       
 
41
    fi
 
42
    host=$1
 
43
    port=$2
 
44
    count=$3
 
45
else
 
46
    if [ X$1 = X ]
 
47
    then
 
48
        show_help       
 
49
    fi
 
50
    host=
 
51
    port=
 
52
    count=$1
 
53
fi
 
54
 
 
55
worker=`which work_queue_worker 2>/dev/null`
 
56
if [ $? != 0 ]
 
57
then
 
58
        echo "$0: please add 'work_queue_worker' to your PATH."
 
59
        exit 1
 
60
fi
 
61
 
 
62
qsub=`which qsub 2>/dev/null`
 
63
if [ $? != 0 ]
 
64
then
 
65
        echo "$0: please add 'qsub' to your PATH."
 
66
        exit 1
 
67
fi
 
68
 
 
69
mkdir -p ${USER}-workers
 
70
cd ${USER}-workers
 
71
cp $worker .
 
72
 
 
73
cat >worker.sh <<EOF
 
74
#!/bin/sh
 
75
./work_queue_worker $arguments $host $port
 
76
EOF
 
77
 
 
78
chmod 755 worker.sh
 
79
 
 
80
for n in `seq 1 $count`
 
81
do
 
82
        qsub -cwd $parameters worker.sh
 
83
done