从shell脚本在docker中启动selenium集线器时遇到问题



shell脚本代码:

#!/bin/bash
cd /Users/lee/Documents/DockerValidation/
docker-compose -f docker-compose.yaml up --force-recreate --scale chrome=3 >>output.txt

从java调用shell脚本的代码

Process p = Runtime.getRuntime().exec("./docker_start.sh");
p.waitFor();

上面的代码触发了shell脚本,seleniumhub启动了。但为了使集线器启动,进程必须继续运行。如果我不给p.waitFor((,我的脚本执行得很快,集线器就没有启动。

我需要帮助来理解如何保持我的中心运行,同时在后台运行这个过程。或者实现我的目标的任何其他选择。

我试图启动并运行我的selenium hub,这样我就可以开始执行我的测试用例了。我做了以下几件事,对我来说很有效。我给了一个等待时间,似乎这就是我的问题所在。

String cmd="./docker_start.sh";
Process p = Runtime.getRuntime().exec(cmd);
p.waitFor(5,TimeUnit.SECONDS);

您需要将其添加到docker撰写文件中

stdin_open: true 
tty: true

,请重试。

https://docs.docker.com/compose/reference/run

最新更新