New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot shutdown the selenium stand alone server by sending 'shutDownSeleniumServer' command #2958

Closed
ashkb opened this Issue Oct 18, 2016 · 15 comments

Comments

Projects
None yet
6 participants
@ashkb

ashkb commented Oct 18, 2016

OS:
Tested only on Windows 7 and Mac 10.10. This issue is not OS specific.

Selenium Version:
3.0.0

Steps to reproduce -

Expected Behavior -

You see OKOK in the browser window and the server shuts down

Actual Behavior -

Server is not shutdown. The browser page displays the following text.

Whoops! The URL specified routes to this help page.
For more information about Selenium Standalone please see the docs and/or visit the wiki. Or perhaps you are looking for the Selenium Standalone console.
Happy Testing!

selenium

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Oct 18, 2016

Member

duplicate of #2852

Member

lukeis commented Oct 18, 2016

duplicate of #2852

@lukeis lukeis closed this Oct 18, 2016

@ashkb

This comment has been minimized.

Show comment
Hide comment
@ashkb

ashkb Oct 18, 2016

@lukeis

The solution given in the linked issue works when you are running with role as node.
It does not work when you run with role as standalone . Is there a way to shutdown the server when it is running in -role standalone.

ashkb commented Oct 18, 2016

@lukeis

The solution given in the linked issue works when you are running with role as node.
It does not work when you run with role as standalone . Is there a way to shutdown the server when it is running in -role standalone.

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Oct 18, 2016

Member

doesn't appear so, no. This shut down command was an artifact of the Selenium RC server, which was removed in 3.0.

Do you have a particular use case you'd like to describe more?

I'm not inclined to add this feature to the standalone server.

Member

lukeis commented Oct 18, 2016

doesn't appear so, no. This shut down command was an artifact of the Selenium RC server, which was removed in 3.0.

Do you have a particular use case you'd like to describe more?

I'm not inclined to add this feature to the standalone server.

@ashkb

This comment has been minimized.

Show comment
Hide comment
@ashkb

ashkb Oct 18, 2016

Hi @lukeis ,

Thanks for getting back quickly.

We have use cases (especially during development) where we are not using the grid setup. We simply bring up the server with standalone role (on both local and remote machines) , run some tests and shutdown the server on test end.
Having the ability to shutdown the server programatically even when grid set up is not used is useful.

ashkb commented Oct 18, 2016

Hi @lukeis ,

Thanks for getting back quickly.

We have use cases (especially during development) where we are not using the grid setup. We simply bring up the server with standalone role (on both local and remote machines) , run some tests and shutdown the server on test end.
Having the ability to shutdown the server programatically even when grid set up is not used is useful.

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Oct 18, 2016

Member

if you're able to launch the process on the remote machine, why can't you also kill it? And, why do you need to kill it?

Member

lukeis commented Oct 18, 2016

if you're able to launch the process on the remote machine, why can't you also kill it? And, why do you need to kill it?

@ashkb

This comment has been minimized.

Show comment
Hide comment
@ashkb

ashkb Oct 19, 2016

In our current implementation, we do not get the process id back when we start the selenium jar, so the only option left is to kill the java process. Killing java blindly is not desirable as there can be other services running on that machine.

When moving to a newer version of selenium we first need to shutdown the server that is running and then deploy and start the new version. We also have a shared pool of machines that are used by different teams, some times of different selenium versions, so shutting down the server after test suite completion is important.

Is there a reason why you think shutdown is not necessary in standalone mode?

ashkb commented Oct 19, 2016

In our current implementation, we do not get the process id back when we start the selenium jar, so the only option left is to kill the java process. Killing java blindly is not desirable as there can be other services running on that machine.

When moving to a newer version of selenium we first need to shutdown the server that is running and then deploy and start the new version. We also have a shared pool of machines that are used by different teams, some times of different selenium versions, so shutting down the server after test suite completion is important.

Is there a reason why you think shutdown is not necessary in standalone mode?

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Oct 19, 2016

Member

There's ways to determine which process id is binding on a particular port, so you don't have to blindly kill all java. And you obviously know the port number already.

It's not a normal type of service to provide to a server. There is not a compelling case to maintain such a thing. It's much more suited to be managed by other software controlling the machine's services (of which there's a large amount of tooling for different OS's and languages to help one with).

Member

lukeis commented Oct 19, 2016

There's ways to determine which process id is binding on a particular port, so you don't have to blindly kill all java. And you obviously know the port number already.

It's not a normal type of service to provide to a server. There is not a compelling case to maintain such a thing. It's much more suited to be managed by other software controlling the machine's services (of which there's a large amount of tooling for different OS's and languages to help one with).

@ashkb

This comment has been minimized.

Show comment
Hide comment
@ashkb

ashkb Oct 20, 2016

Thanks lukies

Regarding the tooling for controlling machines services, would really appreciate it if you could share any that you have used or familiar with for Windows and Mac

ashkb commented Oct 20, 2016

Thanks lukies

Regarding the tooling for controlling machines services, would really appreciate it if you could share any that you have used or familiar with for Windows and Mac

@iltar

This comment has been minimized.

Show comment
Hide comment
@iltar

iltar Dec 16, 2016

@lukeis I see this issue is closed, but I'm having the exact same issue. I use Selenium so I can test my applications. However, I don't want infinite running java processes. How can I stop the server without using the PID?

iltar commented Dec 16, 2016

@lukeis I see this issue is closed, but I'm having the exact same issue. I use Selenium so I can test my applications. However, I don't want infinite running java processes. How can I stop the server without using the PID?

@cgoldberg

This comment has been minimized.

Show comment
Hide comment
@cgoldberg

cgoldberg Dec 16, 2016

Member

@ashkb @iltar

If the standalone server is listening on the default port (4444), this will send it a SIGTERM to terminate the process:
$ lsof -t -i :4444 | xargs kill

Member

cgoldberg commented Dec 16, 2016

@ashkb @iltar

If the standalone server is listening on the default port (4444), this will send it a SIGTERM to terminate the process:
$ lsof -t -i :4444 | xargs kill

@iltar

This comment has been minimized.

Show comment
Hide comment
@iltar

iltar Dec 16, 2016

Imho Selenium should just provide a method of shutting down gracefully

iltar commented Dec 16, 2016

Imho Selenium should just provide a method of shutting down gracefully

@lukeis

This comment has been minimized.

Show comment
Hide comment
@lukeis

lukeis Dec 16, 2016

Member

a kill will do a graceful shutdown (using a higher interrupt level like kill -7 or kill -9 will cause it to not be graceful).

I might be willing to add a new command line flag like: -pidfile <required file location> for those who can't easily figure out how to get the process id (like on windows).

But having a remote shutdown endpoint is counter to most any server process I've come across. I can't think of another server that supplies such a thing.

If you really want the remote shutdown, then i suggest following the advice listed here #2852 (comment) (you don't have to have a 'node' connected to a hub, you can disable the registration request and the poll to attempt to re-attach to a hub).

Member

lukeis commented Dec 16, 2016

a kill will do a graceful shutdown (using a higher interrupt level like kill -7 or kill -9 will cause it to not be graceful).

I might be willing to add a new command line flag like: -pidfile <required file location> for those who can't easily figure out how to get the process id (like on windows).

But having a remote shutdown endpoint is counter to most any server process I've come across. I can't think of another server that supplies such a thing.

If you really want the remote shutdown, then i suggest following the advice listed here #2852 (comment) (you don't have to have a 'node' connected to a hub, you can disable the registration request and the poll to attempt to re-attach to a hub).

@tim-oe

This comment has been minimized.

Show comment
Hide comment
@tim-oe

tim-oe Jan 12, 2017

We have to test the 3 major browsers so we have to run test on windows to verify IE.

look at tomcat, it has shutdown hooks.

if your still supporting standalone server functionality then you should provide a way to shut it down.

tim-oe commented Jan 12, 2017

We have to test the 3 major browsers so we have to run test on windows to verify IE.

look at tomcat, it has shutdown hooks.

if your still supporting standalone server functionality then you should provide a way to shut it down.

@cgoldberg

This comment has been minimized.

Show comment
Hide comment
@cgoldberg

cgoldberg Jan 12, 2017

Member

look at tomcat, it has shutdown hooks

shutdown hooks are just a mechanism for executing custom code during a shutdown... they are not a method for initiating the shutdown.

you should provide a way to shut it down.

#2852 already provides examples of how to terminate the server.

Member

cgoldberg commented Jan 12, 2017

look at tomcat, it has shutdown hooks

shutdown hooks are just a mechanism for executing custom code during a shutdown... they are not a method for initiating the shutdown.

you should provide a way to shut it down.

#2852 already provides examples of how to terminate the server.

@nakulka2

This comment has been minimized.

Show comment
Hide comment
@nakulka2

nakulka2 Apr 17, 2017

@cgoldberg @lukeis @mach6 Thank you for your responses. Both this post and #2852 are helpful. I understand the security implications and thus your hesitation of adding a URL to shut down the standalone server. On the same lines, I also understand that the servlet is just a stop gap solution and will also be decommissioned sometime in the future.

I believe this question keeps popping up on stackoverflow(and other such sites) because the instructions to get quickly started with selenium in https://pypi.python.org/pypi/selenium and other such credible online docs are not accompanied with shutdown instructions. Even if we implicitly know that organizations will use something like a supervisord to manage these standalone servers(if at all they use standalone servers), we should state these assumptions, security implications and simple instructions like these kill -9 in an appendix to the startup page. This will add confidence for more new users of selenium(like me) to get quickly started mess around and cleanup later.

nakulka2 commented Apr 17, 2017

@cgoldberg @lukeis @mach6 Thank you for your responses. Both this post and #2852 are helpful. I understand the security implications and thus your hesitation of adding a URL to shut down the standalone server. On the same lines, I also understand that the servlet is just a stop gap solution and will also be decommissioned sometime in the future.

I believe this question keeps popping up on stackoverflow(and other such sites) because the instructions to get quickly started with selenium in https://pypi.python.org/pypi/selenium and other such credible online docs are not accompanied with shutdown instructions. Even if we implicitly know that organizations will use something like a supervisord to manage these standalone servers(if at all they use standalone servers), we should state these assumptions, security implications and simple instructions like these kill -9 in an appendix to the startup page. This will add confidence for more new users of selenium(like me) to get quickly started mess around and cleanup later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment