0

I have java web application with pool of selenium ChromeDrivers. This pool is exists because of quicker response from REST api (without creating WebDrivers every time).

The problem is, that the chromedrivers are still alive after Tomcat restart.

Is it possible to set some expiration time of each process? Because I cant kill processes manualy every time when I restart the Tomcat.

Or maybe start the chromedrivers with some daemon configuration same as java threads?

Thanks for any answer :)

Altair
  • 325
  • 3
  • 16

1 Answers1

1

You can kill chromedriver.exe processes from your java app as described here: Killing a process using Java

In our projects that's what we do kill the chrome driver processes completely to prevent it from affecting the new runs.

Vladimir Efimov
  • 797
  • 5
  • 13
  • But I have not any Process reference, because of restart of application. And I dont want to every time manually start some .bat file. Same as Linux. – Altair Oct 18 '18 at 13:04
  • I can think of multiple solutions on how to go from "manually" to "programmatically". Most likely you know better what can suit your case but you can 1. create a server that will monitor your apps' availability and in case it is down it will call the bat file to kill chrome drivers 2. you can add some shutdown hook for your app that will be called before actual shutdown. Some more info could be found here https://stackoverflow.com/questions/2921945/useful-example-of-a-shutdown-hook-in-java – Vladimir Efimov Oct 18 '18 at 13:41
  • Yes, but this solution is not familiar for our system of publishing our app. Best way would be set some expiration to the webDriver process which I afraid is not possible. :( – Altair Oct 18 '18 at 13:44
  • I wasn't able to quickly find any implementation of "expiration time" for the process but you still can try implementing it via Java using |execute action after timeout| https://stackoverflow.com/questions/2258066/java-run-a-function-after-a-specific-number-of-seconds So when you start your chromedrivers you can add a Timer to call a function to kill them after some time. – Vladimir Efimov Oct 18 '18 at 15:06