File: chp4_servs.in

package info (click to toggle)
mpich 1.1.0-3
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 22,116 kB
  • ctags: 27,349
  • sloc: ansic: 193,435; sh: 11,172; fortran: 6,545; makefile: 5,801; cpp: 5,020; tcl: 3,548; asm: 3,536; csh: 1,079; java: 614; perl: 183; awk: 168; sed: 70; f90: 62
file content (108 lines) | stat: -rwxr-xr-x 2,440 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#! /bin/sh
#
# Start the p4_server for the machines in the given file, or the current 
# machines table
defport=1234
MPIR_HOME=#MPIR_HOME#
LARCH=#DEFAULT_ARCH#
do_script=/bin/sh
run_dir=$HOME
server_name=serv_p4
for arg in "$@" ; do
    case $arg in 
	-help)
	echo "$0 [ -port=n ] [ -hosts=filename ] [ -arch=name ] [-hunt] [-kill]"
	echo "   [ -pgm=server_program ] [ -startdir=directory ]"
	exit 1
	;;
	
	-port=*)
	defport=`echo $arg | sed 's/-port=//'`
	;;
	
	-startdir=*)
	run_dir=`echo A$arg | sed 's/A-startdir=//'`
	;;

	-hosts=*)
	filename=`echo $arg | sed 's/-hosts=//'`
	;;

	-pgm=*)
	server_name=`echo A$arg | sed 's/A-pgm=//'`
	;;

	-arch=*)
	LARCH=`echo $arg | sed 's/-arch=//'`
	;;

	-hunt)
	do_hunt=1
	;;

	-kill)
	do_kill=1
	echo "Kill not implemented..."
	exit 1
	;;
		
	-echo)
	set -x
	;;

	-trial)
	do_script=cat
	;;

	*)
	echo "Unrecognized argument $arg"
	exit 1
	;;
    esac
done
if [ -z "$filename" ] ; then
    if [ -z "$LARCH" ] ; then 
        LARCH=`$MPIR_HOME/bin/tarch`
    fi
    filename=$MPIR_HOME/util/machines/machines.$LARCH
fi
if [ ! -s $filename ] ; then 
    echo "Can not find file $filename containing machines"
    exit 1
fi
# Change to the startup dir
cd $run_dir
#
serverloc=$MPIR_HOME/lib/$LARCH/ch_p4/$server_name
#
/bin/rm -f .tmp1
sed -e 's/^\([^:]*\):.*$/\1/g' -e '/^#/d' $filename > .tmp1
if test "$do_kill" = 1 ; then	
    /bin/rm -f .tmp
    awk '{     printf( "#RSH_COMMAND# %s %c(ps auxww | grep serv_p4 | grep -v grep | awk %c{printf(%ckill -2 %%s\\n%c, \\$2);}%c -)%c\n", $1, 34, 39, 34, 34, 39, 34 );
    }' .tmp1 > .tmp
    $do_script .tmp
#    /bin/rm -f .tmp
elif test "$do_hunt" = 1 ; then
    # We'd like to send the rsh's to sh, but doing so failed (cat foo | sh
    # would read part of the file and exit).
    /bin/rm -f .tmp
    awk '{ printf( "echo %s\n", $1 );
printf( "#RSH_COMMAND# %s %c(ps auxww | grep serv_p4 | grep -v grep | grep -v #RSH_COMMAND# )%c\n", $1, 34, 34 );
	}' .tmp1 > .tmp
     $do_script .tmp
     /bin/rm -f .tmp
else
    # Using machine[$1] == "" allows use to capture duplicates in the
    # list of machines before starting servers on them
    echo "$defport $serverloc" | awk '{ if (NR==1) { PORT=$1;SERV=$2;} else {
	if (machine[$1]=="") {
	    machine[$1]=PORT;
	    printf( "#RSH_COMMAND# %s %s -o -p %s &\n", $1, SERV, PORT );
	    printf( "echo starting %s on %s with %s\n", SERV, $1, PORT );
	}}}' - .tmp1 | $do_script
fi
/bin/rm -f .tmp1