Skip to content

Commit 4058daa

Browse files
christian.voegeleIvan Senic
christian.voegele
authored and
Ivan Senic
committed
add startup scripts for windows and linux that can be used without docker
add new line - chmod 755 to linux scripts - add log massage that all services are started - small formating issues removed add startup scripts for windows and linux that can be used without docker add new line chmod 755
1 parent 030a738 commit 4058daa

4 files changed

+320
-0
lines changed

start_all_with_inspectIT.bat

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
@echo off
2+
3+
rem usage: Start_all_with_inspectIT.bat <agent_path>
4+
rem the startup scipt must be placed in the same folder than the spring petclinic application
5+
rem the path to the inspectit installation folder and the WAITTIME between the startup of the services
6+
rem !!!!do not use spaces in the path of inspectIT installation folder!!!!
7+
8+
set AGENTDIR=%1
9+
set WAITTIME=10
10+
set /a "x = 0"
11+
12+
rem STARTTYPE, z.B. /B = start without open a new windows, /MIN start minized in new windows
13+
set STARTTYPE=/B
14+
15+
if exist "%AGENTDIR%/inspectit-agent.jar" (
16+
echo "Agent jar found."
17+
cd spring-petclinic-config-server
18+
echo "Starting Configuration Server"
19+
start %STARTTYPE% mvn spring-boot:run
20+
cd ..
21+
22+
:loop1
23+
set /a "x = x + 1"
24+
timeout /T 1 > nul
25+
netstat -a -o -n -proto TCP | findstr 8888
26+
if errorlevel 1 (if %x% leq 60 goto :loop1)
27+
set /a "x = 0"
28+
29+
cd spring-petclinic-discovery-server
30+
echo "Starting Discovery Server"
31+
start %STARTTYPE% mvn spring-boot:run
32+
cd ..
33+
34+
:loop2
35+
set /a "x = x + 1"
36+
timeout /T 1 > nul
37+
netstat -a -o -n -proto TCP | findstr 8761
38+
if errorlevel 1 (if %x% leq 60 goto :loop2) else (
39+
timeout /T %WAITTIME% > nul
40+
start "" http://localhost:8761
41+
)
42+
43+
set /a "x = 0"
44+
45+
cd spring-petclinic-customers-service
46+
echo "Starting Customers Service"
47+
start %STARTTYPE% mvn spring-boot:run -Drun.jvmArguments="-javaagent:%AGENTDIR%/inspectit-agent.jar -Dinspectit.repository=localhost:9070 -Dinspectit.agent.name=customers-service"
48+
cd ..
49+
timeout /T %WAITTIME% > nul
50+
cd spring-petclinic-vets-service
51+
echo "Starting Vets Service"
52+
start %STARTTYPE% mvn spring-boot:run -Drun.jvmArguments="-javaagent:%AGENTDIR%/inspectit-agent.jar -Dinspectit.repository=localhost:9070 -Dinspectit.agent.name=vets-service"
53+
cd ..
54+
timeout /T %WAITTIME% > nul
55+
cd spring-petclinic-visits-service
56+
echo "Starting Visits Service"
57+
start %STARTTYPE% mvn spring-boot:run -Drun.jvmArguments="-javaagent:%AGENTDIR%/inspectit-agent.jar -Dinspectit.repository=localhost:9070 -Dinspectit.agent.name=visits-service"
58+
cd ..
59+
timeout /T %WAITTIME% > nul
60+
cd spring-petclinic-api-gateway
61+
echo "Starting API Gateway"
62+
start %STARTTYPE% mvn spring-boot:run -Drun.jvmArguments="-javaagent:%AGENTDIR%/inspectit-agent.jar -Dinspectit.repository=localhost:9070 -Dinspectit.agent.name=api-gateway"
63+
cd ..
64+
timeout /T %WAITTIME% > nul
65+
cd spring-petclinic-admin-server
66+
echo "Starting Admin Server"
67+
start %STARTTYPE% mvn spring-boot:run -Drun.jvmArguments="-javaagent:%AGENTDIR%/inspectit-agent.jar -Dinspectit.repository=localhost:9070 -Dinspectit.agent.name=admin-server"
68+
cd ..
69+
70+
:loop3
71+
set /a "x = x + 1"
72+
timeout /T 1 > nul
73+
netstat -a -o -n -proto TCP | findstr 8080
74+
if errorlevel 1 (if %x% leq 180 goto :loop3) else ( start "" http://localhost:8080 )
75+
set /a "x = 0"
76+
77+
echo "All Services started!"
78+
79+
) else (
80+
echo Agent jar not found. Specify the path to the inspectIT agent
81+
echo Example: Start_all_with_inspectIT.bat c:/user/inspectIT/agent.
82+
echo In case you have not installed inspectIT go to https://github.com/inspectIT/inspectIT/releases
83+
)

start_all_with_inspectIT.sh

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/bin/sh
2+
#usage: ./start_all_with_inspectIT.sh <path to agent inspectIT agent>
3+
#the startup scipt must be placed in the same folder than the spring petclinic microservice application
4+
#the path to the inspectit installation folder and the waittime between the startup of the services
5+
#!!!!do not use spaces in the path of the inspectIT installation folder!!!!
6+
7+
AGENTDIR="$1"
8+
9+
if [ -e "$AGENTDIR/inspectit-agent.jar" ]
10+
then
11+
12+
echo "Agent jar found."
13+
14+
15+
cd spring-petclinic-config-server
16+
echo "Starting Configuration Server"
17+
mvn spring-boot:run &
18+
cd ..
19+
20+
./wait-for-it.sh localhost:8888 --timeout=60
21+
22+
cd spring-petclinic-discovery-server
23+
echo "Starting Discovery Server"
24+
mvn spring-boot:run &
25+
cd ..
26+
27+
./wait-for-it.sh localhost:8761 --timeout=60
28+
29+
xdg-open http://localhost:8761
30+
31+
cd spring-petclinic-customers-service
32+
echo "Starting Customers Service"
33+
mvn spring-boot:run -Drun.jvmArguments="-javaagent:${AGENTDIR}/inspectit-agent.jar -Dinspectit.repository=localhost:9070 -Dinspectit.agent.name=customers-service" &
34+
cd ..
35+
36+
./wait-for-it.sh localhost:8761 --timeout=60
37+
38+
cd spring-petclinic-vets-service
39+
echo "Starting Vets Service"
40+
mvn spring-boot:run -Drun.jvmArguments="-javaagent:${AGENTDIR}/inspectit-agent.jar -Dinspectit.repository=localhost:9070 -Dinspectit.agent.name=vets-service" &
41+
cd ..
42+
43+
./wait-for-it.sh localhost:8761 --timeout=60
44+
45+
cd spring-petclinic-visits-service
46+
echo "Starting Visits Service"
47+
mvn spring-boot:run -Drun.jvmArguments="-javaagent:${AGENTDIR}/inspectit-agent.jar -Dinspectit.repository=localhost:9070 -Dinspectit.agent.name=visits-service" &
48+
cd ..
49+
50+
./wait-for-it.sh localhost:8761 --timeout=60
51+
52+
cd spring-petclinic-api-gateway
53+
echo "Starting API Gateway"
54+
mvn spring-boot:run -Drun.jvmArguments="-javaagent:${AGENTDIR}/inspectit-agent.jar -Dinspectit.repository=localhost:9070 -Dinspectit.agent.name=api-gateway" &
55+
cd ..
56+
57+
./wait-for-it.sh localhost:8761 --timeout=60
58+
59+
cd spring-petclinic-admin-server
60+
echo "Starting Admin Server"
61+
mvn spring-boot:run -Drun.jvmArguments="-javaagent:${AGENTDIR}/inspectit-agent.jar -Dinspectit.repository=localhost:9070 -Dinspectit.agent.name=admin-server" &
62+
cd ..
63+
64+
./wait-for-it.sh localhost:8080 --timeout=240
65+
xdg-open http://localhost:8080
66+
67+
echo "All Services started!"
68+
69+
else
70+
echo Agent jar not found. Specify the path to the inspectIT agent
71+
echo Example: ./start_all_with_inspectIT.sh /home/user/inspectIT/agent
72+
echo In case you have not installed inspectIT go to https://github.com/inspectIT/inspectIT/releases
73+
fi

stop_all.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
# this command stops all spring petclinic processes executed with spring-boot:run
3+
kill $(ps aux | awk '/[s]pring-petclinic/ && /spring-boot:run/' | awk '{print $2}')

wait-for-it.sh

+161
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
#!/usr/bin/env bash
2+
# Use this script to test if a given TCP host/port are available
3+
4+
cmdname=$(basename $0)
5+
6+
echoerr() { if [[ $QUIET -ne 1 ]]; then echo "$@" 1>&2; fi }
7+
8+
usage()
9+
{
10+
cat << USAGE >&2
11+
Usage:
12+
$cmdname host:port [-s] [-t timeout] [-- command args]
13+
-h HOST | --host=HOST Host or IP under test
14+
-p PORT | --port=PORT TCP port under test
15+
Alternatively, you specify the host and port as host:port
16+
-s | --strict Only execute subcommand if the test succeeds
17+
-q | --quiet Don't output any status messages
18+
-t TIMEOUT | --timeout=TIMEOUT
19+
Timeout in seconds, zero for no timeout
20+
-- COMMAND ARGS Execute command with args after the test finishes
21+
USAGE
22+
exit 1
23+
}
24+
25+
wait_for()
26+
{
27+
if [[ $TIMEOUT -gt 0 ]]; then
28+
echoerr "$cmdname: waiting $TIMEOUT seconds for $HOST:$PORT"
29+
else
30+
echoerr "$cmdname: waiting for $HOST:$PORT without a timeout"
31+
fi
32+
start_ts=$(date +%s)
33+
while :
34+
do
35+
(echo > /dev/tcp/$HOST/$PORT) >/dev/null 2>&1
36+
result=$?
37+
if [[ $result -eq 0 ]]; then
38+
end_ts=$(date +%s)
39+
echoerr "$cmdname: $HOST:$PORT is available after $((end_ts - start_ts)) seconds"
40+
break
41+
fi
42+
sleep 1
43+
done
44+
return $result
45+
}
46+
47+
wait_for_wrapper()
48+
{
49+
# In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692
50+
if [[ $QUIET -eq 1 ]]; then
51+
timeout $TIMEOUT $0 --quiet --child --host=$HOST --port=$PORT --timeout=$TIMEOUT &
52+
else
53+
timeout $TIMEOUT $0 --child --host=$HOST --port=$PORT --timeout=$TIMEOUT &
54+
fi
55+
PID=$!
56+
trap "kill -INT -$PID" INT
57+
wait $PID
58+
RESULT=$?
59+
if [[ $RESULT -ne 0 ]]; then
60+
echoerr "$cmdname: timeout occurred after waiting $TIMEOUT seconds for $HOST:$PORT"
61+
fi
62+
return $RESULT
63+
}
64+
65+
# process arguments
66+
while [[ $# -gt 0 ]]
67+
do
68+
case "$1" in
69+
*:* )
70+
hostport=(${1//:/ })
71+
HOST=${hostport[0]}
72+
PORT=${hostport[1]}
73+
shift 1
74+
;;
75+
--child)
76+
CHILD=1
77+
shift 1
78+
;;
79+
-q | --quiet)
80+
QUIET=1
81+
shift 1
82+
;;
83+
-s | --strict)
84+
STRICT=1
85+
shift 1
86+
;;
87+
-h)
88+
HOST="$2"
89+
if [[ $HOST == "" ]]; then break; fi
90+
shift 2
91+
;;
92+
--host=*)
93+
HOST="${1#*=}"
94+
shift 1
95+
;;
96+
-p)
97+
PORT="$2"
98+
if [[ $PORT == "" ]]; then break; fi
99+
shift 2
100+
;;
101+
--port=*)
102+
PORT="${1#*=}"
103+
shift 1
104+
;;
105+
-t)
106+
TIMEOUT="$2"
107+
if [[ $TIMEOUT == "" ]]; then break; fi
108+
shift 2
109+
;;
110+
--timeout=*)
111+
TIMEOUT="${1#*=}"
112+
shift 1
113+
;;
114+
--)
115+
shift
116+
CLI="$@"
117+
break
118+
;;
119+
--help)
120+
usage
121+
;;
122+
*)
123+
echoerr "Unknown argument: $1"
124+
usage
125+
;;
126+
esac
127+
done
128+
129+
if [[ "$HOST" == "" || "$PORT" == "" ]]; then
130+
echoerr "Error: you need to provide a host and port to test."
131+
usage
132+
fi
133+
134+
TIMEOUT=${TIMEOUT:-15}
135+
STRICT=${STRICT:-0}
136+
CHILD=${CHILD:-0}
137+
QUIET=${QUIET:-0}
138+
139+
if [[ $CHILD -gt 0 ]]; then
140+
wait_for
141+
RESULT=$?
142+
exit $RESULT
143+
else
144+
if [[ $TIMEOUT -gt 0 ]]; then
145+
wait_for_wrapper
146+
RESULT=$?
147+
else
148+
wait_for
149+
RESULT=$?
150+
fi
151+
fi
152+
153+
if [[ $CLI != "" ]]; then
154+
if [[ $RESULT -ne 0 && $STRICT -eq 1 ]]; then
155+
echoerr "$cmdname: strict mode, refusing to execute subprocess"
156+
exit $RESULT
157+
fi
158+
exec $CLI
159+
else
160+
exit $RESULT
161+
fi

0 commit comments

Comments
 (0)