forked from lavcraft/spring-react-or-not-react
-
Notifications
You must be signed in to change notification settings - Fork 2
/
runner.sh
65 lines (61 loc) · 1.77 KB
/
runner.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
55
56
57
58
59
60
61
62
63
64
65
#!/bin//bash
EXTRA=()
INSTANCES_NUMBER=1
for i in "$@"
do
case $i in
--port=*)
PORT="${i#*=}"
shift # past arguments
;;
-p=*|--profile=*)
PROFILES="${i#*=}"
shift # past argument
;;
-in=*|--instances-number=*)
INSTANCES_NUMBER="${i#*=}"
shift # past argument
;;
-v|--verbous)
VERBOUS=true
shift # past argument
;;
*) # unknown option
EXTRA+=("$1") # save it in an array for later
shift # past argument
;;
esac
done
set -- "${EXTRA[@]}" # restore positional parameters
if [[ "${EXTRA[0]}" == "start" ]]; then
echo "STARTING SERVICE : "
echo "PROFILES = ${PROFILES} "
echo "INSTANCES NUMBER = ${INSTANCES_NUMBER}"
echo "SERVICE = ${EXTRA[1]} "
echo "BASE PORT = ${PORT} "
if [[ "${VERBOUS}" == "true" ]]; then
if [[ $((INSTANCES_NUMBER)) -gt 1 ]]; then
for i in $(seq 0 "$((INSTANCES_NUMBER - 1))")
do
eval "java -Dspring.profiles.active=default,${PROFILES} -Dserver.port=$((PORT + i)) -Dspring.application.id=${i} -jar ${EXTRA[1]} &"
done
else
eval "java -Dspring.profiles.active=default,${PROFILES} -jar ${EXTRA[1]} &"
fi
else
if [[ $((INSTANCES_NUMBER)) -gt 1 ]]; then
for i in $(seq 0 "$((INSTANCES_NUMBER - 1))")
do
eval "java -Dspring.profiles.active=default,${PROFILES} -Dserver.port=$((PORT + i)) -Dspring.application.id=${i} -jar ${EXTRA[1]} &>/dev/null &"
done
else
eval "java -Dspring.profiles.active=default,${PROFILES} -jar ${EXTRA[1]} &>/dev/null &"
fi
fi
elif [[ "${EXTRA[0]}" == "stop" ]]; then
eval "pkill -9 -f ${EXTRA[1]}"
elif [[ "${EXTRA[0]}" == "status" ]]; then
eval "ps aux | grep java"
else
echo "Unknown command"
fi