Add "threads" command to the gerrit.sh script

Make it easier to create Gerrit server thread dumps by providing a
command for that in the gerrit.sh. This also makes it easier to explain
people in the Gerrit discussion group how to provide a thread dump.

Change-Id: I92b75d1ed4c19feba715c83857e94fde79e45c16
This commit is contained in:
Saša Živkov 2015-01-15 15:37:43 +01:00
parent f1cbbe8739
commit ed819f30bc

View File

@ -47,7 +47,7 @@
usage() {
me=`basename "$0"`
echo >&2 "Usage: $me {start|stop|restart|check|status|run|supervise} [-d site]"
echo >&2 "Usage: $me {start|stop|restart|check|status|run|supervise|threads} [-d site]"
exit 1
}
@ -63,6 +63,13 @@ running() {
return 0
}
thread_dump() {
test -f $1 || return 1
PID=`cat $1`
$JSTACK $PID || return 1
return 0;
}
get_config() {
if test -f "$GERRIT_CONFIG" ; then
if test "x$1" = x--int ; then
@ -258,6 +265,8 @@ if test -z "$JAVA" ; then
exit 1
fi
JSTACK=${JAVA:0:${#JAVA}-5}/jstack
#####################################################
# Add Gerrit properties to Java VM options.
#####################################################
@ -536,6 +545,16 @@ case "$ACTION" in
exit 3
;;
threads)
if running "$GERRIT_PID" ; then
thread_dump "$GERRIT_PID"
exit 0
else
echo "Gerrit not running?"
fi
exit 3
;;
*)
usage
;;