#!/bin/sh
#
# tries to figure out the PID and send signal -3 to provoke a stacktrace of all threads
#

# sane defaults
#export LOGBACK_OPTS=-Dlogback.configurationFile=/etc/svc-runner/logging.d/logback-stdout.xml

# No need to source /etc/default/svc-runner

SVCRUNNER_PID=$(ps -ef -u $(id -u) |egrep "org.clazzes.svc.runner.Main$" |awk '{print $2}')

if [ -z "${SVCRUNNER_PID}" ] ; then
  echo "ERROR: Unable to detect main PID of eventual svc-runner process."
  exit 11
fi

echo "INFO: Sending signal -3 to main PID of svc-runner, ${SVCRUNNER_PID}"
kill -3 ${SVCRUNNER_PID}

# if we want all the hoopla from osgi-runner-dump someone has to "port" that

echo "GOOD: Back from sending signal -3 to main PID of svc-runner, ${SVCRUNNER_PID}"

exit 0
