Reputation: 379
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?
Upvotes: 17
Views: 56691
Reputation: 51
If jetty as maven plugin, you stop the server by pressing Ctrl+C and press Y to confirm terminate.
Upvotes: 3
Reputation: 49525
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
Upvotes: 24