Docker容器运行pipe理器过早closures
我正在使用这里描述的pipe理器运行一个有多个进程的Docker容器(来实现一个LAMP环境)。 一切工作正常,但是当我停止容器的MySQL进程不会得到正确的终止,即使我已经设置了pipe理员的pidproxy在pipe理员configuration
[program:mysql] command=/usr/bin/pidproxy /run/mysqld/mysqld.pid /bin/sh -c "exec /usr/bin/mysqld_safe"
当我通过nsenter访问容器并重新启动MySQL守护进程
supervisorctl restart mysql
关机完成时不会在下次出现错误时抛出。 所以我认为主pipeconfiguration正确。 对我来说,似乎docker(我正在运行1.2.0)在mysqld仍然closures的时候终止了容器。
编辑
通过使用-e debug
开关运行supervisord
,我能够debugging一些更多的细节。
closures与supervisorctl restart mysql
通过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
这是第一次尝试之前的stream程结构:
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
因此,尽pipepid 1463
在/run/mysqld/mysqld.pid
获得了正确的/run/mysqld/mysqld.pid
,但是在dockerclosures之前, pid 1129
会导致麻烦。 这是主pipe的pidproxy中的错误还是可以通过不同的configuration修复?
我相信Docker只会等待十秒钟才能杀死一个试图停止(或重新启动)的容器。 这是要求的行动最终被执行,而不是只是挂起。 您可以使用“docker stop”或“docker restart”中的“–time”参数configuration时间段。
我有一个类似的问题,我解决了不使用mysql_safe,而是直接启动mysql。 我通过查看在ps aux
概述中生成的命令mysql_safe来做到这一点。
也许它失败,因为mysql_safe
不会创build一个正确的父 – >subprocess关系?
无论如何,我的configuration看起来像这样,如果我使用你的mysql进程作为模板:
[program:mysql] command=/usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --log-erro