【发布时间】:2019-08-10 23:05:27
【问题描述】:
我正在使用here 中描述的主管运行具有多个进程的 docker 容器(以实现 LAMP 环境)。一切正常,但是当我停止容器时,即使我在主管配置中设置了主管的 pidproxy,MySQL 进程也没有正确终止
[program:mysql]
command=/usr/bin/pidproxy /run/mysqld/mysqld.pid /bin/sh -c "exec /usr/bin/mysqld_safe"
当我通过 nsenter 访问容器并使用
重新启动 MySQL 守护进程时supervisorctl restart mysql
关机完成,下次出现时不会抛出错误。所以我认为主管配置正确。对我来说,docker(我正在运行 1.2.0)似乎在 mysqld 仍在关闭时提前终止了容器。
编辑
我可以通过使用-e debug 开关运行supervisord 来调试更多细节。
通过 nsenter 使用 supervisorctl restart mysql 关闭:
DEBG fd 17 closed, stopped monitoring <POutputDispatcher at 39322256 for <Subprocess at 38373280 with name mysql in state RUNNING> (stderr)>
DEBG fd 14 closed, stopped monitoring <POutputDispatcher at 39324128 for <Subprocess at 38373280 with name mysql in state RUNNING> (stdout)>
DEBG killing mysql (pid 1128) with signal SIGTERM
INFO stopped: mysql (exit status 0)
DEBG received SIGCLD indicating a child quit
CRIT reaped unknown pid 1129)
DEBG received SIGCLD indicating a child quit
外部通过docker restart container_name:
DEBG fd 17 closed, stopped monitoring <POutputDispatcher at 39290136 for <Subprocess at 38373280 with name mysql in state RUNNING> (stderr)>
DEBG fd 14 closed, stopped monitoring <POutputDispatcher at 39290424 for <Subprocess at 38373280 with name mysql in state RUNNING> (stdout)>
DEBG killing mysql (pid 7871) with signal SIGTERM
INFO stopped: mysql (exit status 0)
DEBG received SIGCLD indicating a child quit
这是第一次尝试前的流程结构:
1128 S 0:00 /usr/bin/python /usr/bin/pidproxy /run/mysqld/mysqld.pid /usr/bin/mysqld_safe
1129 S 0:00 \_ /bin/sh /usr/bin/mysqld_safe
1463 Sl 0:00 \_ /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --log-erro
因此,虽然 pid 1463 像在 /run/mysqld/mysqld.pid 中一样被正确收割,但 pid 1129 会导致麻烦,因为 docker 在容器消失之前将其关闭。是主管的 pidproxy 中的错误还是可以通过不同的配置修复?
【问题讨论】:
标签: mysql docker supervisord