diff --git a/gerrit-pgm/src/main/resources/com/google/gerrit/pgm/init/gerrit.sh b/gerrit-pgm/src/main/resources/com/google/gerrit/pgm/init/gerrit.sh index 57411efaeb..a5a8ed5159 100755 --- a/gerrit-pgm/src/main/resources/com/google/gerrit/pgm/init/gerrit.sh +++ b/gerrit-pgm/src/main/resources/com/google/gerrit/pgm/init/gerrit.sh @@ -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 ;;