0

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.

  • 1
    Docker is going to execute the command given to it it and exit. of the shell script has no mechanism inside of it to make it wait then it will run and exit. Perhaps you should look at something like supervisord to keep it running in the background. – Josh Beauregard Nov 05 '19 at 18:45

2 Answers2

0

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);
0

You need to add this to docker-compose file

stdin_open: true 
tty: true

,try again.

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

eamazaj
  • 74
  • 1
  • 3