apache / apache/rocketmq-docker

apache/rocketmq image It seems unable to gracefully shut down

Open
#123 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Shell
Stars
706
Forks
246
PR merge metrics
No merged PRs in 30d

Description

I tried two versions of `Apache/RocketMQ: 5.3.2` and `Apache/RocketMQ: 5.3.3` located on Dockerhub, and found that the process with PID 1 started by the container is a shell script rather than a JVM
This violates the best practice of containers. If the shutdown signal forwarding is not manually handled, the JVM should be made a PID1 process to ensure that the JVM shutdown hook is executed correctly, rather than forcing a shutdown after timeout

---
我尝试了位于 dockerhub 的 `apache/rocketmq:5.3.2` `apache/rocketmq:5.3.3` 两个版本, 发现容器启动的 PID 为 1 的进程都是 shell 脚本而非 JVM

这违反了容器的最佳实践, 如果没有手动处理关机信号转发, 应该让 JVM 成为PID1进程, 以确保JVM关机挂钩正确执行, 而非超时后强制关闭

参考:

容器内的进程:
```log
rocketmq 1 0 0 23:38 ? 00:00:00 sh mqbroker
rocketmq 7 1 0 23:38 ? 00:00:00 sh /home/rocketmq/rocketmq-5.3.3/bin/runbroker.sh -Drmq.logback.configurationFile=/home/rocketmq/rocketmq-5.3.3/conf/rmq.broker.logback.xml org.apache.rocketmq.broker.BrokerStartup
rocketmq 14 7 17 23:38 ? 00:00:12 /opt/java/openjdk/bin/java -server -Xms2g -Xmx2g -Xmn1g -XX:MaxDirectMemorySize=1g -XX:+UseG1GC -XX:G1HeapRegionSize=16m -XX:G1ReservePercent=25 -XX:InitiatingHeapOccupancyPercent=30 -XX:SoftRefLRU
rocketmq 171 0 0 23:39 pts/0 00:00:00 /bin/sh -c [ -e /bin/bash ] && (/bin/bash || exit 0) || /bin/sh
rocketmq 177 171 0 23:39 pts/0 00:00:00 /bin/sh -c [ -e /bin/bash ] && (/bin/bash || exit 0) || /bin/sh
rocketmq 178 177 0 23:39 pts/0 00:00:00 /bin/bash

```

`mqbroker` 启动脚本部分内容:
sh 开启了子进程
```shell
if [ "$enable_proxy" = true ]; then
args_for_proxy=$other_args" -pm local"
if [ "$broker_config" != "" ]; then
args_for_proxy=${args_for_proxy}" -bc "${broker_config}
fi
sh ${ROCKETMQ_HOME}/bin/runbroker.sh -Drmq.logback.configurationFile=$ROCKETMQ_HOME/conf/rmq.proxy.logback.xml org.apache.rocketmq.proxy.ProxyStartup ${args_for_proxy}
else
args_for_broker=$other_args
if [ "$broker_config" != "" ]; then
args_for_broker=${args_for_broker}" -c "${broker_config}
fi
sh ${ROCKETMQ_HOME}/bin/runbroker.sh -Drmq.logback.configurationFile=$ROCKETMQ_HOME/conf/rmq.broker.logback.xml org.apache.rocketmq.broker.BrokerStartup ${args_for_broker}
fi

```

目前在 docker 环境中部署时, `docker compose down` 卸载或 `docker compose restart` 重启能明显感觉到迟缓, 因为没有人处理关机信号, docker 在超时后强制结束容器, 所以始终有固定的延迟

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.