You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@activemq.apache.org by "Petr Újezdský (Jira)" <ji...@apache.org> on 2021/08/27 12:40:00 UTC
[jira] [Created] (AMQ-8364) ActiveMQ runs at different PID when
using console version
Petr Újezdský created AMQ-8364:
----------------------------------
Summary: ActiveMQ runs at different PID when using console version
Key: AMQ-8364
URL: https://issues.apache.org/jira/browse/AMQ-8364
Project: ActiveMQ
Issue Type: Bug
Affects Versions: 5.15.10
Reporter: Petr Újezdský
When using {{/opt/activemq/bin/activemq console}} the jar invocation is done using {{exec}}. However this is not done properly, the {{java}} process itself still has different PID than the main process.
This is problem inside docker environment where the app should run with PID 1 to properly listen to {{KILL}} signal to stop gracefully. I have filed a bug downstream in docker version https://github.com/rmohr/docker-activemq/issues/34#issuecomment-907159964 but found out the problem is in ActiveMQ itself.
When run using {{console}} parameter, the code goes
{code}
case "$1" in
...
console)
invoke_console
exit $?
;;
{code}
{code}
invoke_console(){
...
EXEC_OPTION="exec"
...
invokeJar "$ACTIVEMQ_PIDFILE"
...
}
{code}
{code}
invokeJar(){
...
else
$EXEC_OPTION $DOIT_PREFIX "\"$JAVACMD\" $ACTIVEMQ_OPTS $ACTIVEMQ_DEBUG_OPTS \
-Dactivemq.classpath=\"${ACTIVEMQ_CLASSPATH}\" \
-Dactivemq.home=\"${ACTIVEMQ_HOME}\" \
-Dactivemq.base=\"${ACTIVEMQ_BASE}\" \
-Dactivemq.conf=\"${ACTIVEMQ_CONF}\" \
-Dactivemq.data=\"${ACTIVEMQ_DATA}\" \
$ACTIVEMQ_CYGWIN \
-jar \"${ACTIVEMQ_HOME}/bin/activemq.jar\" $COMMANDLINE_ARGS" $DOIT_POSTFIX
RET="$?"
fi
...
{code}
The problem is here
{code}
$EXEC_OPTION $DOIT_PREFIX "\"$JAVACMD\"
{code}
This translates into something like
{code}
exec sh -c 'java some.jar args'
{code}
and the PIDs are as follows (note the wrong PID 23 for java itself)
{code}
activemq@a9d909468041:/opt/apache-activemq-5.15.10$ ps axu
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
activemq 1 0.0 0.0 4296 708 ? Ss 12:05 0:00 sh -c "/opt/java/bin/java" -Xms64M -Xm
activemq 23 29.3 1.5 5481824 251840 ? Sl 12:05 0:12 /opt/java/bin/java -Xms64M -Xmx1G -Dja
activemq 108 0.1 0.0 18144 3172 pts/0 Ss 12:06 0:00 /bin/bash
activemq 164 0.0 0.0 36644 2832 pts/0 R+ 12:06 0:00 ps axu
{code}
IMHO the code should be something like
{code}
$EXEC_OPTION $DOIT_PREFIX "$EXEC_OPTION \"$JAVACMD\"
{code}
that translates into something like
{code}
exec sh -c 'exec java some.jar args'
{code}
and the PIDs will be correct
{code}
activemq@a9d909468041:/opt/apache-activemq-5.15.10$ ps axu
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
activemq 1 161 1.6 5282132 275824 ? Ssl 12:08 0:11 /opt/java/bin/java -Xms64M -Xmx1G -Dja
activemq 61 0.5 0.0 18144 3220 pts/0 Ss 12:08 0:00 /bin/bash
activemq 82 0.0 0.0 36644 2788 pts/0 R+ 12:08 0:00 ps axu
{code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)