SeleniumHQ/selenium — pull request #199 by joaogbcravo (2014-04-10 16:38:52+00:00)
Title: Added gracefully shutdown function to selenium server

I have filled the CLA.

Description
===========
Implements the necessary functions to let selenium server have a way to be gracefully shutdown.

Reason
======
After discuss on IRC channel, I think there is not a gracefully way to kill selenium server, I mean, to shutdown selenium server after we handles current sessions. This feature is important to make sure that tests are not broken when someones wants to kill the selenium server.

Benefits
========
Let selenium server have a way to shutdown gracefully.

Drawbacks
=========
...

Implementation
=========
The actual implementation of selenium server have this command to call:
http://SERVER:5555/selenium-server/driver/?cmd=shutDownSeleniumServer
But this call just call system.exit.

My implementation that can be called in similar way:
http://SERVER:5555/selenium-server/driver/?cmd=gracefullyShutDownSeleniumServer
waits for node webdriverSessions.getSessions().size() to be equal to zero before call system.exit