forked from spring-attic/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·53 lines (42 loc) · 1.18 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
#!/bin/bash
set -e
mkdir -p target/logs
ports[configserver]=8888
ports[eureka]=8761
ports[customers]=9000
ports[stores]=8081
ports[customersui]=9900
function check_port() {
p=${ports[$1]}
netstat -tlnp 2>&1 | cut --b 21-41 | grep $p && used=$p
if [ "$used" != "" ]; then
echo Port ${used} in use for app $1, please kill the 'process' and try again
exit 1
fi
}
function run_app() {
NAME=$1
PREFIX=
[ "$1" == "stores" ] && NAME=store && PREFIX=customers-stores/rest-microservices-
[ "$1" == "customers" ] && PREFIX=customers-stores/rest-microservices-
[ "$1" == "customersui" ] && NAME=customers-stores-ui && PREFIX=customers-stores/
check_port $NAME
DIR=$PREFIX$NAME
if [ -f $DIR/.settings.xml ]; then
SETTINGS='--settings .settings.xml'
fi
TMPHOME=`pwd`
cmd="mvn $SETTINGS spring-boot:run"
if [ "$1" == "customersui" ]; then
cmd="spring run app.groovy"
fi
(cd $DIR; $cmd > "${TMPHOME}"/target/logs/$1.log &)
echo "Launching $1 (logs in target/logs/$1.log)"
}
apps=$*
if [ -z $1 ]; then
apps='configserver eureka customers stores customersui'
fi
for f in $apps; do
run_app $f
done