用于安装supervisor的buildout配方
项目描述
变更历史
0.18 (未知)
0.17 (2011-07-28)
增加了对进程组[nueces]的支持
0.16 (2011-03-07)
修复supervisorctl以使用unix_http_server(由Domen Kožar,NiteoWeb提供支持,由Hexagon IT赞助)
0.15 (2011-03-05)
除了inet_http_server外,还增加了对unix_http_server的支持(由Domen Kožar,NiteoWeb提供支持,由Hexagon IT赞助)
0.14 (2010-12-10)
增加了对supervisord的umask选项的支持[servilio@mcmaster.ca]
将用于与supervisord进程进行身份验证的凭据从supervisorctl脚本移动到配置文件。由于zc.buildout的bug 180705,脚本现在是全球可读的。[servilio@mcmaster.ca]
0.13 (2010-12-07)
Supervisor的‘nocleanup’选项现在可以从Buildout补丁中配置(由Damien Letournel提供支持)
0.12 (2010-08-04)
在监控器配置文件中引用环境变量,否则监控器无法正确传递给例如 memmon 等 [Fred van Dijk]
0.11 (2010-08-02)
现在可以从 Buildout 配置 Supervisor 的 'childlogdir' 选项 [Jonathan Ballet]
在监控器配置文件中包含 [include] 功能。请参阅 http://supervisord.org/configuration.html#include [ycadour]
0.10.1 (2010-07-27)
更新了关于如何使用 memmon 事件监听器的文档 [lucielejard]
0.10 (2010-06-03)
添加了环境变量 PATH 的选项 [lucielejard]
添加了对禁用监控器部分(例如 http、rpc 和 ctl)的支持 [Domen Kozar]
0.9 (2009-11-04)
应用了 Jonathan Ballet 的补丁:生成的控制脚本在以自定义端口运行时不会自动连接到创建的 supervisord。[lucielejard]
0.8 (2009-04-27)
使控制脚本中每个进程可以设置额外的选项。[nkryptic]
0.7 (2009-01-27)
添加了 'plugins' 选项,以便我们可以安装额外的 eggs(监控器插件)[mustapha]
对事件监听器部分进行了一些修复 [mustapha]
更新了测试 [mustapha]
0.6 (2008-11-10)
现在可以指定用于运行程序的账户。[amos]
0.5 (2008-08-23)
添加事件监听器选项,用作事件通知框架。针对与监控器 memmon 事件监听器的使用 [aburkhalter]
0.4 (2008-06-12)
使用动态脚本名称以允许多个集群 [gawel]
确保在未使用 zope 的食谱时创建日志目录 [gawel]
0.3 (2008-06-01)
更新文档和测试 [mustapha]
pep8 修饰 [mustapha]
使控制脚本能够传递参数。[hannosch]
将所有指定的选项(如服务器 URL 和用户名)放入生成的控制脚本中。这允许直接运行它。[hannosch]
0.2 (2008-04-23)
使可能向命令传递参数,这样就可以使用带有参数的 ctl 脚本,如 'fg' 用于 zope 实例,或 -no-detach 或类似参数用于其他程序 [mustapha]
更新测试 [mustapha]
0.1 (2008-04-21)
使用 ZopeSkel 创建了配方 [Mustapha Benali]。
详细文档
使用此配方将执行以下操作
安装 supervisor 及其所有依赖项。
在 bin 目录中生成 supervisord、supervisorctl 和 memmon 脚本
生成一个配置文件,供 supervisord 和 supervisorctl 脚本使用
支持的选项
此配方支持以下选项
- 部分
启用监控器部分的列表。默认为 “http ctl rpc”
- 插件
您想要配方安装的额外 eggs。例如:superlance
- http-socket
用于 http 管理的 “inet” 或 “unix” 套接字。默认为 “inet”。
- 文件
UNIX 域套接字的路径(例如 /tmp/supervisord.sock),supervisor 将监听 HTTP/XML-RPC 请求。
- chmod
在启动时将 UNIX 权限模式位更改为此值。
- 端口
supervisord 监听的端口号。例如:9001。可以是 host:port 的形式,例如 127.0.0.1:9001。默认为 127.0.0.1:9001
- 用户
进行 supervisord 身份验证所需的用户名
- 密码
进行 supervisord 身份验证所需的密码
- supervisord-conf
配方将 supervisord 配置文件放置的完整路径。默认为 ${buildout:directory}/parts/${name}/supervisord.conf
- childlogdir
存储由 Supervisor 管理的进程日志文件的目录的完整路径。默认为 ${buildout:directory}/var/log
- logfile
supervisord 日志文件的完整路径。默认为 ${buildout:directory}/var/log/supervisord.log
- pidfile
supervisord 的 pid 文件。默认为 ${buildout:directory}/var/supervisord.pid
- logfile-maxbytes
活动日志文件在使用前可能消耗的最大字节数。默认为 50MB
- logfile-backups
保留的活动日志文件轮换产生的备份数量。默认值为10
- loglevel
日志级别。可以是critical(严重)、error(错误)、warn(警告)、info(信息)、debug(调试)、trace(跟踪)或blather。默认值为info
- umask
supervisord进程的umask。默认值为022。
- nodaemon
如果为true,supervisord将在前台启动而不是作为守护进程。默认值为false
- nocleanup
防止supervisord在启动时清除任何现有的AUTO子日志文件。对调试很有用。默认值为false
- serverurl
用于访问supervisord服务器的URL。默认值为http://127.0.0.1:9001
- programs
您想要supervisord控制的程序列表。每行一个。行格式如下
- priority process_name [(process_opts)] command [[args] [directory] [[redirect_stderr]]
[user]]
[[args]是您想要传递给command的任何数量的参数。它必须放在[]内(例如:[-v fg])。下面有示例。如果没有给出,则redirect_stderr默认为false。如果没有给出,则目录选项默认为包含命令的目录。可选的process_opts参数在supervisord配置中设置进程的附加选项。它必须放在()内,并且必须包含以空格分隔的选项的key=value格式 - 即:(autostart=false startsecs=10)。可选的user参数指定进程应该以哪个用户ID运行(如果supervisord以root运行)。
在大多数情况下,您只需要给出前4个部分
priority process_name command [[args]]
- eventlisteners
您希望supervisord作为子进程运行以订阅事件通知的事件监听器列表。每行一个。有关事件的supervisor文档请参阅http://supervisord.org/manual/current/events.html。
processname events command [[args]]
events是事件类型名称的逗号分隔列表(不带空格),监听器希望接收这些类型的通知。
Supervisor提供了一个名为memmon的事件监听器,可用于在子进程达到一定的内存限制时重启supervisord。请注意,您需要定义变量user、password和serverurl(在上述支持的选项中描述),才能使用memmon监听器。定义一个memmon事件监听器的示例,该监听器每60秒分析一次内存使用情况,并在需要时重启,可能如下所示:
MemoryMonitor TICK_60 ${buildout:bin-directory}/memmon [-p process_name=200MB]
- groups
成为组一部分的程序列表。每行一个。行格式如下
priority group_name program_names
program_names是程序名称的逗号分隔列表。
- env-path
环境变量PATH,例如/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin
示例用法
我们将首先创建一个使用recipy的buildout
>>> write('buildout.cfg', ... """ ... [buildout] ... parts = supervisor ... index = http://pypi.python.org/simple ... [zeo] ... location = /a/b/c ... [instance1] ... location = /e/f ... [instance2] ... location = /g/h ... ... [supervisor] ... recipe = fourdigits.recipe.supervisor ... plugins = ... superlance ... port = 9001 ... user = mustapha ... password = secret ... serverurl = http://supervisor.mustap.com ... programs = ... 10 zeo ${zeo:location}/bin/runzeo ${zeo:location} ... 20 instance1 ${instance1:location}/bin/runzope ${instance1:location} true ... 30 instance2 (autostart=false) ${instance2:location}/bin/runzope true ... 40 maildrophost ${buildout:bin-directory}/maildropctl true ... 50 other ${buildout:bin-directory}/other [-n 100] /tmp ... 60 other2 ${buildout:bin-directory}/other2 [-n 100] true ... 70 other3 (startsecs=10) ${buildout:bin-directory}/other3 [-n -h -v --no-detach] /tmp3 true www-data ... eventlisteners = ... Memmon TICK_60 ${buildout:bin-directory}/memmon [-p instance1=200MB] ... HttpOk TICK_60 ${buildout:bin-directory}/httpok [-p site1 -t 20 https://127.0.0.1:8080/] ... groups = ... 10 services zeo,instance1 ... 20 others other,other2,other3 ... """)
Chris Mc Donough说
Note however that the "instance" script Plone uses to start Zope when passed "fg" appears to use os.system, so the process that supervisor is controlling isnt actually Plone, it's the controller script. This means that "stop" and "start" tend to not do what you want. It's far better to use "runzope", which actually execs the Python process which becomes Zope See also http://supervisord.org/manual/current/subprocesses.html#nondaemonizing_of_subprocesses
运行buildout会得到
>>> print system(buildout) Getting distribution for 'zc.recipe.egg'. ... Installing supervisor. ... Generated script '/sample-buildout/bin/supervisorctl'. <BLANKLINE>
检查是否有来自superlance的‘crashmail’、‘memmon’和‘httpok’脚本
>>> ls(sample_buildout, 'bin') - buildout - crashmail - httpok - memmon - supervisorctl - supervisord
现在您可以像这样运行supervisord
$ bin/supervisord
并使用supervisorctl进行控制
$ bin/supervisorctl
通过supervisor的memmon事件监听器进行的内存监控将通过以下方式执行
$ bin/memmon
现在,看看生成的supervisord.conf文件
>>> cat('parts', 'supervisor', 'supervisord.conf') #doctest: +REPORT_NDIFF <BLANKLINE> [supervisord] childlogdir = /sample-buildout/var/log logfile = /sample-buildout/var/log/supervisord.log logfile_maxbytes = 50MB logfile_backups = 10 loglevel = info pidfile = /sample-buildout/var/supervisord.pid umask = 022 nodaemon = false nocleanup = false <BLANKLINE> [inet_http_server] port = 9001 username = mustapha password = secret <BLANKLINE> [supervisorctl] serverurl = http://supervisor.mustap.com username = mustapha password = secret <BLANKLINE> [rpcinterface:supervisor] supervisor.rpcinterface_factory=supervisor.rpcinterface:make_main_rpcinterface <BLANKLINE> [program:zeo] command = /a/b/c/bin/runzeo process_name = zeo directory = /a/b/c priority = 10 redirect_stderr = false <BLANKLINE> <BLANKLINE> [program:instance1] command = /e/f/bin/runzope process_name = instance1 directory = /e/f priority = 20 redirect_stderr = true <BLANKLINE> <BLANKLINE> [program:instance2] command = /g/h/bin/runzope process_name = instance2 directory = /g/h/bin priority = 30 redirect_stderr = true autostart = false <BLANKLINE> [program:maildrophost] command = /sample-buildout/bin/maildropctl process_name = maildrophost directory = /sample-buildout/bin priority = 40 redirect_stderr = true <BLANKLINE> <BLANKLINE> [program:other] command = /sample-buildout/bin/other -n 100 process_name = other directory = /tmp priority = 50 redirect_stderr = false <BLANKLINE> <BLANKLINE> [program:other2] command = /sample-buildout/bin/other2 -n 100 process_name = other2 directory = /sample-buildout/bin priority = 60 redirect_stderr = true <BLANKLINE> <BLANKLINE> [program:other3] command = /sample-buildout/bin/other3 -n -h -v --no-detach process_name = other3 directory = /tmp3 priority = 70 redirect_stderr = true user = www-data startsecs = 10 <BLANKLINE> [eventlistener:Memmon] command = /sample-buildout/bin/memmon -p instance1=200MB events = TICK_60 process_name=Memmon environment=SUPERVISOR_USERNAME='mustapha',SUPERVISOR_PASSWORD='secret',SUPERVISOR_SERVER_URL='http://supervisor.mustap.com' <BLANKLINE> [eventlistener:HttpOk] command = /sample-buildout/bin/httpok -p site1 -t 20 https://127.0.0.1:8080/ events = TICK_60 process_name=HttpOk environment=SUPERVISOR_USERNAME='mustapha',SUPERVISOR_PASSWORD='secret',SUPERVISOR_SERVER_URL='http://supervisor.mustap.com' <BLANKLINE> [group:services] programs = zeo,instance1 priority = 10 <BLANKLINE> [group:others] programs = other,other2,other3 priority = 20
如果我们查看生成的supervisord脚本,我们会看到配置文件作为带有‘-c’选项的参数给出
>>> cat('bin', 'supervisord') ... <BLANKLINE> ... <BLANKLINE> import sys; sys.argv.extend(["-c","/sample-buildout/parts/supervisor/supervisord.conf"]) <BLANKLINE> import supervisor.supervisord <BLANKLINE> if __name__ == '__main__': supervisor.supervisord.main()
控制脚本包含所有指定的选项,如服务器URL和用户名。这使得可以立即运行它
>>> cat('bin', 'supervisorctl') ... <BLANKLINE> ... <BLANKLINE> import sys; sys.argv[1:1] = ["-c","/sample-buildout/parts/supervisor/supervisord.conf"] <BLANKLINE> import supervisor.supervisorctl <BLANKLINE> if __name__ == '__main__': supervisor.supervisorctl.main(sys.argv[1:])
Memmon将所有工作委托给egg的memmon Python脚本本身
>>> cat('bin', 'memmon') ... <BLANKLINE> ... <BLANKLINE> import superlance.memmon <BLANKLINE> if __name__ == '__main__': superlance.memmon.main()
日志目录由recipe创建
>>> ls(sample_buildout, 'var') d log
您还可以指定一个自定义端口来运行supervisor,控制脚本将自动尝试连接到指定的端口
>>> write('buildout.cfg', ... """ ... [buildout] ... parts = supervisor ... index = http://pypi.python.org/simple/ ... ... [supervisor] ... recipe = fourdigits.recipe.supervisor ... port = 9005 ... programs = ... 50 other ${buildout:bin-directory}/other [-n 100] /tmp ... """)
在这里我们指定了管理员将在端口9005上启动。我们可以看到这也在控制脚本中设置
>>> _ = system(buildout) >>> cat('bin', 'supervisorctl') ... <BLANKLINE> ... <BLANKLINE> import sys; sys.argv[1:1] = ["-c","/sample-buildout/parts/supervisor/supervisord.conf"] <BLANKLINE> import supervisor.supervisorctl <BLANKLINE> if __name__ == '__main__': supervisor.supervisorctl.main(sys.argv[1:])
可以通过Unix套接字而不是TCP来运行http服务器
>>> write('buildout.cfg', ... """ ... [buildout] ... parts = supervisor ... index = http://pypi.python.org/simple/ ... ... [supervisor] ... recipe = fourdigits.recipe.supervisor ... http-socket = unix ... user = foobar ... password = foobar ... file = /tmp/supervisor.sock ... programs = ... 50 other ${buildout:bin-directory}/other [-n 100] /tmp ... """) >>> _ = system(buildout) >>> cat('parts', 'supervisor', 'supervisord.conf') #doctest: +REPORT_NDIFF <BLANKLINE> ... <BLANKLINE> [unix_http_server] file = /tmp/supervisor.sock username = foobar password = foobar chmod = 0700 <BLANKLINE> [supervisorctl] serverurl = unix:///tmp/supervisor.sock username = foobar password = foobar <BLANKLINE> ... <BLANKLINE>
贡献者
Mustapha Benali,作者
Hanno Schlichting,贡献者
gawel,贡献者
aburkhalter,贡献者
Amos Latteier,贡献者
Jacob Radford,贡献者
Jonathan Ballet,贡献者
Domen Kozar,贡献者
Lucie Lejard,贡献者
Servilio Afre Puentes,贡献者
Juan A. Diaz (nueces),贡献者
下载
项目详情
fourdigits.recipe.supervisor-0.18dev.tar.gz的散列值
算法 | 散列摘要 | |
---|---|---|
SHA256 | 2a572533034df875a4f7b719016712e7196716edbf66cfdb8ac2421f6714c071 |
|
MD5 | f0f9e1ed7e82a7eb7dacc21cf59c0dcb |
|
BLAKE2b-256 | 211190e40b18e1ebf571c8b483d9aeb1f4996e3d50c97c7be5315e1e14da233e |