3

I have written batch files to run Selenium Grid2 server and to register the nodes to it but how can I shutdown the server ?

I can't kill the batch processes because their ids are just "cmd.exe" and I don't want to kill all cmd.exe because there might something else running on cmd that I need.

Thanks

5 Answers 5

5

The Selenium Grid2 server has a lifecycle manager that you can use to shut it down.

You can activate it by visiting this url:

http://yourHubIP:4444/lifecycle-manager?action=shutdown

This will quit the server, you can use a command line tool like wget for windows to hit it.

wget --post-data action=shutdown action=shutdown http://localhost:4444/lifecycle-manager

It does not have anymore actions at this moment, I looked at the code. Also this doesn't do a graceful shutdown, all running tests will be killed instantly.

Sign up to request clarification or add additional context in comments.

3 Comments

The link to the selenium documentation returns a 404.
newer version any1?
@Ja8zyjits It is still in the code: github.com/SeleniumHQ/selenium/blob/…
1

cmd.exe and java process are marred by same problem of non-identifiable child process running in them. Fortunately java has a solution and we can use that.

I guess you are using something like java -jar selenium-server.jar in your batch file. If yes then the selenium server is running as java process. So there is no need to kill cmd.exe. Instead you have to identify the java process running selenium server.

In order to identify java process, use jps -l on command prompt. 'jps' comes with jdk by default, and it will tell you the process id of the selenium server running. You can simply kill this process.

Hope this would solve the problem.

3 Comments

When I run this command I get 6 processes with no information . i.e. "4352 -- process information unavailable" ?
if there is only one process then you can kill it without a worry (given selenium server is running). I can tell you more if you could provide me code of you bat file.
java -Xms128m -Xmx900m -XX:MaxPermSize=512m -jar selenium-server-standalone-2.28.0.jar -role hub
1

I think you can have your answer here by specifying the selenium grid port.

Comments

0

What i can advise you to do is the following:

Make sure you create a unique user at your domain to start the server and nodes. With that you can actually use the Taskkill command that is native to Windows OS to terminate all the instances of cmd.exe that has been started by that user.

I had this problem on my work months ago (creating a user selenium-webdriver) and using this has proven to be very useful, since we ended up with a routine that reboots all the server and nodes everyday.

Comments

0

I'm kind of late to the party, but have also ran into this exact same issue. The fix for me was to run an HTTP server in the same container which kills the processes when a certain endpoint is called. Please refer to this article on a way to achieve this:

https://medium.com/@andras.patka/building-a-custom-selenium-standalone-chrome-docker-image-with-a-http-endpoint-for-shutdown-735594dfb093

If you run selenium in a container, then you can make sure that the only java process that is running is the one that is running selenium.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.