跳转到主要内容

collective.hostout 插件,用于在部署期间启动和停止 supervisor

项目描述

安装

hostout.supervisorcollective.hostout 的插件。Hostout 是一个 zc.buildout 食谱。

首先,你需要一个使用 supervisor 的正常工作的 buildout。这里有一个非常简单的例子

>>> write('buildout.cfg',
... """
... [buildout]
... parts = helloworld
...
... [helloworld]
... recipe = zc.recipe.egg:scripts
... eggs = zc.recipe.egg
... initialization = import sys
...   main=lambda: sys.stdout.write('all your hosts are below to us')
... entry-points = helloworld=__main__:main
...
... [supervisor]
... recipe = collective.recipe.supervisor
... programs = 10 helloworld bin/helloworld
...
... """)
>>> print system('bin/buildout -N')
Installing helloworld.
Generated script '/sample-buildout/bin/helloworld'.
>>> print system('bin/helloworld')
all your hosts are belong to us

在 Google 中搜索“buildout”和您喜欢的应用框架,以了解如何构建它。

接下来,我们将 hostout 添加到我们的 buildout 中,并通过使用 extends 选项添加 hostout.supervisor 插件来扩展 hostout。

>>> write('buildout.cfg',
... """
... [buildout]
... parts = helloworld host
...
... [helloworld]
... recipe = zc.recipe.egg:scripts
... eggs = zc.recipe.egg
... initialization = import sys
...   main=lambda: sys.stdout.write('all your hosts are below to us')
... entry-points = helloworld=__main__:main
...
... [supervisor]
... recipe = collective.recipe.supervisor
... programs = 10 helloworld bin/helloworld
...
... [host]
... recipe = collective.hostout
... host = 127.0.0.1:10022
... extends = hostout.supervisor
... parts = hellowworld supervisor
...
... """)
>>> print system('bin/buildout -N')
    Updating helloworld.
    Installing host.
    Generated script '/sample-buildout/bin/hostout'.
    ...

hostout.supervisor 命令

>>> print system('bin/hostout host')
    cmdline is: bin/hostout host1 [host2...] [all] cmd1 [cmd2...] [arg1 arg2...]
    Valid commands are:
    ...
       supervisorboot     : Installs supervisor into your init.d scripts in order to ensure that supervisor is started on boot
    ...
       supervisorctl      : Takes command line arguments and runs supervisorctl on the remote host
       supervisorshutdown : Shutdown the supervisor daemon
       supervisorstartup  : Start the supervisor daemon
    ...

可以使用以下选项

supervisor

要停止和重新启动的 supervisor 部分的名称

init.d

如果设置,supervisord 脚本将被链接到 init.d,这样任何机器重启也将启动 supervisor。

部署期间的自动启动和关闭

此外,supervisor 插件将在预部署期间关闭 supervisor,并在后部署期间启动 supervisor。

>>> print system('bin/hostout host1 deploy')
    Hostout: Running command 'predeploy' from 'hostout.supervisor.fabfile'
    Logging into the following hosts as :
        127.0.0.1
    [127.0.0.1] sudo: /var/lib/plone/host1/bin/supervisorctl shutdown || echo 'Failed to shutdown'
    ...
    Hostout: Running command 'postdeploy' from 'hostout.supervisor.fabfile'
    ...
    [127.0.0.1] sudo: /var/lib/plone/host1/bin/supervisord
    ...
    [127.0.0.1] sudo: /var/lib/plone/host1/bin/supervisorctl status
    ...
    Hostout: Running command 'postdeploy' from 'collective.hostout.fabfile'
    ...

致谢

Dylan Jay (software at pretaweb dot com)

发布历史

1.05 (2014-05-29)

  • 整理说明文件 [Jean Jordaan]

  • 修复 bootstrip 安装/卸载 [Adam Terrey]

1.0a4 (2010-04-13)

  • 允许 buildout 用户仅进行部署

1.0a3 (2010-03-21)

  • 当需要以 root 身份启动时,引入了新的 sudosupervisor [Dylan Jay]

  • 使其与 collective.hostout 1.0a5 兼容 [Dylan Jay]

  • 改进了启动和关闭功能,因此使用 buildout-user + reload 而不是“supervisor shutdown” [Dylan Jay]

1.0a2 (2010-06-03)

  • 添加 falfile 入口点

  • 更好的 init.d 脚本

1.0a1 (2010-02-13)

  • 从collective.hostout移除

  • 升级到fabric 1.0和python 2.6

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源分发

hostout.supervisor-1.0a5.tar.gz (6.2 kB 查看哈希)

上传时间

由以下提供支持