用面料和主管部署Web应用程序 - 叹气会导致服务器终止



我们正在使用主管部署Python Web应用程序。在部署时,Web应用程序是通过BuildOut安装在服务器上的,并且使用Collective.Recipe.Supervisor创建了一个用于运行主管的脚本。该脚本在部署过程结束时通过织物脚本调用。问题是,当部署脚本完成后,将叹气信号发送到该过程,这会导致主管重新启动(按照以下行:https://github.com/supervisor/supervisor/supervisor/supervisor/blob/blob/master/master/supervisor/supervisord/supervisord/supervisord/supervisord.py#l300),但是由于某种原因,Web应用程序终止后不会重新启动。以下内容没有日志输出:

2012-10-24 15:23:51,510 WARN received SIGHUP indicating restart request
2012-10-24 15:23:51,511 INFO waiting for app-server to die
2012-10-24 15:23:54,650 INFO waiting for app-server to die
2012-10-24 15:23:57,653 INFO waiting for app-server to die
2012-10-24 15:24:00,657 INFO waiting for app-server to die
2012-10-24 15:24:01,658 WARN killing 'app-server' (28981) with SIGKILL
2012-10-24 15:24:01,659 INFO stopped: app-server (terminated by SIGKILL)

所以我有两个问题。第一个是,有人知道为什么主管在叹息上重启吗?我找不到任何解释,并且没有命令行选项可以关闭此行为。第二个问题是,我们如何解决我们面临的问题?我们尝试使用NoHup开始主管,但仍会收到叹息。奇怪的是,当我登录服务器,手工启动主管并注销时,这不会发生。

这是BuildOut生成的主管脚本:

#!/usr/bin/python2.6
import sys
sys.path[0:0] = [
'/home/username/.buildout/eggs/supervisor-3.0b1-py2.6.egg',
'/home/username/.buildout/eggs/meld3-0.6.9-py2.6.egg',
'/home/username/.buildout/eggs/distribute-0.6.30-py2.6.egg',
]

import sys; sys.argv.extend(["-c","/home/username/app_directory/parts/supervisor/supervisord.conf"])
import supervisor.supervisord
if __name__ == '__main__':
sys.exit(supervisor.supervisord.main())

这是主管的配置文件,也是由BuildOut生成的:

[supervisord]
childlogdir = /home/username/app_directory/var/log
logfile = /home/username/app_directory/var/log/supervisord.log
logfile_maxbytes = 50MB
logfile_backups = 10
loglevel = info
pidfile = /home/username/app_directory/var/supervisord.pid
umask = 022
nodaemon = false
nocleanup = false
[unix_http_server]
file = /home/username/app_directory/supervisor.sock
username = username
password = apasswd
chmod = 0700
[supervisorctl]
serverurl = unix:///home/username/app_directory/supervisor.sock
username = username
password = apasswd
[rpcinterface:supervisor]
supervisor.rpcinterface_factory=supervisor.rpcinterface:make_main_rpcinterface
[program:app-server]
command = /home/username/app_directory/bin/gunicorn --bind 0.0.0.0:5000 app:wsgi
process_name = app-server
directory = /home/username/app_directory/bin
priority = 50
redirect_stderr = false
directory = /home/username/app_directory

我们不想在真正理解问题之前安装一个修补版的主管版本,因此任何信息都将不胜感激。

预先感谢

SIGHUP上重新启动或重新加载是Linux系统编程中的常见实践。问题是为什么部署结束后要获得SIGHUP。由于主管可以正确地进行卫生(因为您可以启动并注销并将起作用),因此可以通过构建机器人来将重新加载信号发送给主管,这表明需要重新启动WebApp,因为代码已更改。

因此,主管启动应用程序关闭,以便使用新代码启动应用程序。但是应用程序不会在给定的超时中停止,主管决定使用SIGKILL挂起并杀死它。

要解决问题,您需要在主管要求时教该应用程序关闭。

主管文档清楚地表明,将叹线器发送到主管过程将"停止所有进程,从其找到的第一个配置文件中重新加载配置,然后重新启动所有进程"。

ref -http://supervisord.org/running.html#signal handlers

也许您的过程表现不佳;看来主管进行了几次尝试将其很好地关闭,但随后决定需要严重杀戮:

process.py:560
# kill processes which are taking too long to stop with a final
# sigkill.  if this doesn't kill it, the process will be stuck
# in the STOPPING state forever.
self.config.options.logger.warn(
    killing %r (%s) with SIGKILL' % (self.config.name, self.pid))
self.kill(signal.SIGKILL)

也许杀死电话失败了?

您可能已经遇到了此错误:https://github.com/supervisor/supervisor/supervisor/sissues/121

解决方法是降级主管,直到已发布的版本修复为止。

陷入了完全相同的问题,降级到3.0a10解决了它。

最新更新