-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlauncher.sh
More file actions
executable file
·54 lines (45 loc) · 1.72 KB
/
launcher.sh
File metadata and controls
executable file
·54 lines (45 loc) · 1.72 KB
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
#!/bin/bash
##Script to start and stop the multiple servers easily
##Handwritten with love
##Use start to start them, stop to stop them
## And don't forget to stop the servers
## The id of the process are stored in a file, if lost you have to stop them manually
## WARNING !
## Please note this is a BASH SCRIPT, it will NOT WORK ON WINDOWS, except with some workarounds or WSL.
PidsFile=".PidsFile.txt"
BuildDir="."
#Selon le premier argument
case "$1" in
'stop')
echo "Try to stop"
while read -r line ; do
echo Tue $line
kill $line
done < $PidsFile #Par cette ligne on spécifie dans quel fichier sont stockés les PID, en mettant le fichier dans l'entrée standard de la boucle qui est lu par read
rm $PidsFile
echo
echo "Serveurs arrêté"
;;
'start')
echo "try to start"
java -classpath $BuildDir CLI nameserver 9000 & (echo $! >> $PidsFile)
sleep 0.5 # Pour lui laisser le temps de démarrer
java -classpath $BuildDir CLI dataserver n1 127.0.0.1 9000 8001 & (echo $! >> $PidsFile)
java -classpath $BuildDir CLI dataserver n2 127.0.0.1 9000 8002 & (echo $! >> $PidsFile)
java -classpath $BuildDir CLI dataserver n3 127.0.0.1 9000 8003 & (echo $! >> $PidsFile)
java -classpath $BuildDir CLI dataserver n4 127.0.0.1 9000 8004 & (echo $! >> $PidsFile)
sleep 0.5
echo
echo "Serveurs démarrés"
echo "PIDs : "
cat $PidsFile
echo
;;
*)
echo "Utility to start and stop servers easily"
echo "Logs by all the servers will be displayed in this terminal"
echo "Usage :"
echo " ./launcher.sh start - Start the nameserver and 3 dataservers"
echo " ./launcher.sh stop - Stop the servers launched by this utility"
;;
esac