简体   繁体   中英

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

shell script code:

#!/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

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

the above code triggers the shell script, and selenium hub is up. 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.

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. 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

stdin_open: true 
tty: true

,try again.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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