Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I stop Jetty

Tags:

jetty

I am new to Jetty and client/server architectures.

I managed to write a jetty server in eclipse and it works.

But how I can stop a jetty server? I heard something about stop.jar and start.jar. Where I can find it? Is it integrated in jetty-all-jar?

like image 858
Salvadora Avatar asked Feb 20 '13 13:02

Salvadora


People also ask

How do I stop a Jetty server from terminal?

The Jetty server can be stopped with ctrl+c in the terminal window.

How do you stop a Jetty server in eclipse?

BTW, as to your question in title: mvn jetty:stop fails for you (see also manual for stopPort and stopKey )? By the way. I solved my problem. after a little searching i got run-jetty-run (code.google.com/p/run-jetty-run) for eclipse.


1 Answers

The various jetty-all.jar artifacts can be used for embedded jetty usage. If you decide to use this jar, you have to manage your own startup / shutdown.

Update: 2015 : As of Jetty 9, the use of jetty-all.jar as a dependency is deprecated. This is because as of Jetty 9, it is now impossible to satisfy "all" of Jetty in a single aggregate jar. There are components of Jetty that cannot be included as they will cause problems with this aggregate jar. The future of Jetty, with HTTP/2 support, also makes this aggregate jar less useful as a dependency.

Typical Embedded Mode usage

The thread that starts the server:

Server server = new Server();
// various server configuration lines
// ...

// Start server (on current thread)
server.start();

// Have current thread wait till server is done running
server.join();

The other thread that tells the server to shutdown

// Have server stop running
server.stop();

At this point the original thread's wait on server.join(); is complete and that thread continues to run.

Standard Distribution Usage

If you use the standard distribution available from download.eclipse.org/jetty/ you have the start.jar that can be used to start/stop jetty itself.

Once you have unpacked your jetty-distribution, you'll find a start.jar in the top most directory. This can be used as the following.

The process that starts jetty:

$ java -jar start.jar STOP.PORT=28282 STOP.KEY=secret

The process that stops jetty:

$ java -jar start.jar STOP.PORT=28282 STOP.KEY=secret --stop
like image 180
Joakim Erdfelt Avatar answered Sep 17 '22 15:09

Joakim Erdfelt