在运行命令之前等待发生事情
multiwait的Python项目详细描述
多等待
multiwait允许在满足条件后运行命令。为了 示例:在redis加载完它的 数据集到内存中,或在锁定文件消失后。
这些设置在yaml文件中给出,例如:
defaults:timeout:60conditions:-redis-dataset-loaded-file-absent:path:/path/to/lockfilewarmup:10test_interval:1-file-present:path:/path/to/sockettimeout:15
然后将multiwait命令指向设置和 想要运行:
$ multiwait --settings /path/to/settings.yaml echo foo
这里echo foo只在redis完成数据集加载后运行 在内存中,/path/to/lockfile已消失,并且/path/to/socket 存在。
也可以直接从命令行指定简单条件:
$ multiwait --cond file-absent:path=/path/to/lockfile,timeout=3 echo foo
该命令将替换multiwait进程,保持相同的pid,因此 在流程管理器中使用是安全的。
如果没有指定命令,检查所有条件并用非零退出 如果其中一个失败,则返回代码。
条件
运行命令之前要满足的条件在 conditions设置文件的键。它必须是一个包含 条件定义。每个条目都必须包含一个具有条件的对象 名称作为单键,参数作为定义。作为捷径,你可以 如果不带参数或者您只想 使用默认值;在上面的示例中redis-dataset-loaded是 redis-dataset-loaded: {}的快捷方式。
所有条件至少接受以下参数:
- 超时
- 条件的最大执行时间,在放弃前的几秒钟。这个 默认为无超时。
- 热身
- 在开始测试病情之前,睡眠一段时间。 默认设置为无预热时间。
- 测试间隔
- 两次测试之间的间隔(秒)。默认值为0.1秒。
全局默认参数可以在中的defaults顶级键中指定 设置文件。它们被特定条件覆盖;在 上面的示例所有条件都有60秒超时,除了file-present 有15秒的超时时间。
内置条件
已加载redis数据集
Wait until Redis has finished loading its dataset in memory. Requires the redis package.
- ^{tt11}$: the host of the Redis server (default: “localhost”)
- ^{tt12}$: the port number of the Redis server (default: 6379)
- ^{tt13}$: the password used to connect to the Redis server (default: no password)
- ^{tt14}$: ignore connection errors (default: True)
文件存在
Wait until a file is present on the filesystem.
- ^{tt15}$ (required): the path of the file
文件不存在
Wait until a file is not present on the filesystem.
- ^{tt15}$ (required): the path of the file
X11运行
Wait until the X11 system is running.
- ^{tt17}$: for systems not using Xauthority cookies, try to connect to this display (default: “:0”)
新闻
0.1
第一个版本,大多未经测试,请勿使用;)