-
Notifications
You must be signed in to change notification settings - Fork 0
/
start_services.sh
executable file
·43 lines (37 loc) · 1.22 KB
/
start_services.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
#!/bin/bash
# $# checks for commandline arguments
# No arguments => start all services
# Example arguments => ./start_services.sh service-discovery auth-service
# $! gives the pid of the last command
# nohup runs a jar in the background
# set env vars
echo "Setting env vars..."
chmod 777 ./set_env_vars_local.sh
source ./set_env_vars_local.sh # sets the env variables in the current terminal session
if [ "$#" -eq 0 ]; then
echo "Starting all services...";
services=(service-discovery api-gateway auth-service note-service)
for i in "${services[@]}"
do
cd ./"$i"
gradle build -x test
if [ "$i" = "service-discovery" ]; then
gradle bootRun > ../logs/"${i}.log" 2>&1 & # write into the log/pid file starting from first micro-service
echo $! $i > ../pid.file
else
gradle bootRun > ../logs/"${i}.log" 2>&1 & # append to the log/pid file
echo $! $i >> ../pid.file
fi
cd ..
done
else
for service in "$@"
do
echo "Starting $service...";
cd ./"$service"
gradle build -x test
gradle bootRun > ../logs/"$service.log" 2>&1 &
echo $! "$service" >> ../pid.file
cd ..
done
fi