我如何阻止码头 [英] How do I stop Jetty

查看:80
本文介绍了我如何阻止码头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Jetty和客户端/服务器体系结构的新手.

I am new to Jetty and client/server architectures.

我设法在eclipse中编写了一个码头服务器,并且可以正常工作.

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

但是如何停止码头服务器?我听到了有关stop.jar和start.jar的信息.在哪里可以找到它?它是否集成在码头所有罐子中?

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?

推荐答案

各种jetty-all.jar工件都可以用于嵌入式码头.如果决定使用此jar,则必须管理自己的启动/关闭.

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.

更新:2015 :从Jetty 9开始,已不再使用jetty-all.jar作为依赖项.这是因为从Jetty 9开始,现在不可能在单个集合罐中满足Jetty的全部"要求. Jetty的某些组件无法包含,因为它们会导致该集合罐出现问题.具有HTTP/2支持的Jetty的未来,也将使此聚合jar作为依赖项的用处不大.

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.

嵌入式模式的典型用法

启动服务器的线程:

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();

此时,原始线程在server.join();上的等待已完成,并且该线程继续运行.

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

标准分发使用情况

如果您使用 download.eclipse.org/jetty/中提供的标准发行版,则可以使用start.jar用于启动/停止码头本身.

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.

一旦您解开了码头的行李箱,您将在最顶层的目录中找到一个start.jar.可以用作以下内容.

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.

启动码头的过程:

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

停止码头的过程:

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

这篇关于我如何阻止码头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆