简体   繁体   English

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

[英]Having issues with starting a selenium hub in docker from shell script

shell script code: shell 脚本代码:

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

Code to invoke the shell script from java从 java 调用 shell 脚本的代码

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

the above code triggers the shell script, and selenium hub is up.上述代码触发 shell 脚本,selenium 集线器启动。 but in order for the hub to be up, the process has to keep on running.但是为了使集线器启动,该过程必须继续运行。 If I dont give p.waitFor() my script executes quickly and the hub is not up.如果我不给 p.waitFor() 我的脚本会快速执行并且集线器没有启动。

I need help with understanding on how to keep my hub up and at the same time run this process in background.我需要帮助来了解如何让我的集线器保持正常运行,同时在后台运行这个过程。 Or any other alternatives to achieve my goal.或任何其他替代方案来实现我的目标。

I was trying to get my selenium hub,up and running, so that I can start executing my test cases.我试图让我的 selenium 集线器启动并运行,这样我就可以开始执行我的测试用例了。 I did the following and it worked for me.我做了以下事情,它对我有用。 I gave a wait time, seems it was the issue in my case.我给了一个等待时间,似乎这是我的问题。

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

You need to add this to docker-compose file您需要将此添加到 docker-compose 文件

stdin_open: true 
tty: true

,try again. ,再试一次。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM