我们正在使用 supervisor 来部署一个 python web 应用程序。在部署时,Web 应用程序通过 buildout 安装在服务器上,并使用collective.recipe.supervisor 创建运行主管的脚本。此脚本在部署过程结束时由结构脚本调用。问题是,当部署脚本完成时,会向进程发送 SIGHUP 信号,这会导致主管重新启动(根据这一行:https ://github.com/Supervisor/supervisor/blob/master/supervisor/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)
所以我有两个问题。第一个是,有人知道为什么主管会在 SIGHUP 上重新启动吗?我找不到任何解释,也没有命令行选项可以关闭此行为。第二个问题是,我们如何解决我们面临的问题?我们尝试使用 nohup 启动主管,但仍然收到 SIGHUP。奇怪的是,当我登录服务器、手动启动主管并注销时,这不会发生。
这是 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
在真正理解问题之前,我们不想安装补丁版本的主管,因此任何信息都将受到高度赞赏。
提前致谢