-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·54 lines (42 loc) · 1.38 KB
/
run.sh
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
# Compile all the .java files in the current directory
# and run the application
# Expect four arguments:
# 1. The top number to sum up to (default: 1000)
# 2. The number of workers (default: 2)
# 3. The ip address of the server (default: localhost)
# 4. The port number of the server (default: 1099)
# Set the default values
top=1000
workers=2
ip=localhost
port=1099
# If the user has specified a top number, use it
if [ $# -gt 0 ]; then
top=$1
fi
# If the user has specified a number of workers, use it
if [ $# -gt 1 ]; then
workers=$2
fi
# If the user has specified an ip address, use it
if [ $# -gt 2 ]; then
ip=$3
fi
# If the user has specified a port number, use it
if [ $# -gt 3 ]; then
port=$4
fi
# Compile all the .java files in the current directory
javac *.java
# Run the server
gnome-terminal --title=SERVER -- /bin/sh -c "java -Djava.security.manager=allow -Djava.security.policy=java.policy MOMServer $port; bash"
# Wait for the server to start
sleep 1
# Run the master in a new terminal
gnome-terminal --title=MASTER -- /bin/sh -c "java -Djava.security.manager=allow -Djava.security.policy=java.policy DisSumMaster $top $workers $ip; bash"
sleep 1
# Run workers in new terminal windows
for i in `seq 1 $workers`
do
gnome-terminal --title=WORKER$i -- /bin/sh -c "java -Djava.security.manager=allow -Djava.security.policy=java.policy DisSumWorker $ip; bash"
done