mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-04 01:59:35 +00:00
fixed /suspend method for /threadmanager/api (used to call stop() instead of suspend() on the thread)
This commit is contained in:
1 parent
d6781a9169
commit
1b02410159
2 files changed
+38
-1
No files matched your search
Executable
+37
@@ -0,0 +1,37 @@
|
||||
#!/bin/bash
|
||||
ACTION=$1
|
||||
TELNET_PORT=$2
|
||||
if [ -z "${TELNET_PORT}" ]; then
|
||||
TELNET_PORT=14888
|
||||
fi
|
||||
|
||||
rawurlencode() {
|
||||
local string="${1}"
|
||||
local strlen=${#string}
|
||||
local encoded=""
|
||||
local pos c o
|
||||
for (( pos=0 ; pos<strlen ; pos++ )); do
|
||||
c=${string:$pos:1}
|
||||
case "$c" in
|
||||
[-_.~a-zA-Z0-9] ) o="${c}" ;;
|
||||
* ) printf -v o '%%%02x' "'$c"
|
||||
esac
|
||||
encoded+="${o}"
|
||||
done
|
||||
echo "${encoded}" # You can either set a return variable (FASTER)
|
||||
REPLY="${encoded}" #+or echo the result (EASIER)... or both... :p
|
||||
}
|
||||
|
||||
# First find the threadmanager bundle ID and start it:
|
||||
tmbid=$( { echo "ss com.sap.sse.threadmanager"; sleep 1; } | telnet localhost ${TELNET_PORT} | grep "^[0-9][0-9]* .* *com.sap.sse.threadmanager" | sed -e 's/^\([0-9]*\) .* *com.sap.sse.threadmanager.*$/\1/' )
|
||||
echo "Starting Thread Manager bundle #$tmbid"
|
||||
{ echo "start $tmbid"; sleep 1; } | telnet localhost ${TELNET_PORT}
|
||||
# Now that the threadmanager bundle is started we can get all thread names and perform an action on them:
|
||||
curl "http://localhost:8888/threadmanager/api/threads" 2>/dev/null | jq -r '.[].name' | while read i; do
|
||||
echo "
|
||||
$i"
|
||||
thread_name_url_encoded=$(rawurlencode "$i")
|
||||
echo "URL-encoded: ${thread_name_url_encoded}"
|
||||
curl "http://localhost:8888/threadmanager/api/threads/${thread_name_url_encoded}/${ACTION}"
|
||||
done
|
||||
echo
|
||||
@@ -64,7 +64,7 @@ public class ThreadManager extends StreamingOutputUtil {
|
||||
Thread.enumerate(threads);
|
||||
for (Thread t : threads) {
|
||||
if (t != null && t.getName().equals(name)) {
|
||||
t.stop();
|
||||
t.suspend();
|
||||
result.put("status", "OK");
|
||||
found = true;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user