Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b3W3uHbHAmM3orhn7b
34 lines
1.3 KiB
Bash
Executable File
34 lines
1.3 KiB
Bash
Executable File
# Shared helpers. Source me from the other scripts.
|
|
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
. "$HERE/scripts/env.sh"
|
|
JAR="$HERE/target/gateway-mvc-1.0.0.jar"
|
|
LOGDIR="${LOGDIR:-/tmp/gwmvc-logs}"; mkdir -p "$LOGDIR"
|
|
|
|
# Kill by main-class pattern kept in a variable so this very script's command line never matches it.
|
|
stop_all() {
|
|
local pat='gateway-mvc-1.0.0[.]jar|scripts/Upstream[.]java'
|
|
for p in $(ps -eo pid,args | grep -E "$pat" | grep -v grep | awk '{print $1}'); do kill "$p" 2>/dev/null; done
|
|
sleep 2
|
|
}
|
|
|
|
wait_http() { for _ in $(seq 1 60); do curl -s -o /dev/null "$1" && return 0; sleep 1; done; return 1; }
|
|
|
|
start_upstream() {
|
|
setsid nohup java "$HERE/scripts/Upstream.java" 9091 > "$LOGDIR/upstream.log" 2>&1 < /dev/null &
|
|
wait_http http://localhost:9091/hello
|
|
}
|
|
|
|
# start_gateway <port> [extra spring args...]
|
|
start_gateway() {
|
|
local port="$1"; shift
|
|
setsid nohup java -jar "$JAR" --server.port="$port" "$@" > "$LOGDIR/gateway-$port.log" 2>&1 < /dev/null &
|
|
wait_http "http://localhost:$port/diag/thread"
|
|
}
|
|
|
|
# show <curl args...> : prints the command, then status line + interesting headers + body
|
|
show() {
|
|
echo "\$ curl -i $*"
|
|
curl -si "$@" | tr -d '\r' | grep -viE '^(date|content-length|connection|keep-alive|transfer-encoding):'
|
|
echo
|
|
}
|