[英]What's the simplest way to setup a web server in java?
I have server daemons running on several machines. 我有在几台计算机上运行的服务器守护程序。 I decide to expose the internal stats of the server daemons for monitoring and statistic, using HTTP protocol. 我决定使用HTTP协议公开服务器守护程序的内部统计信息,以进行监视和统计。
So, what's the simplest way to do this? 那么,最简单的方法是什么?
If the stats are a small number of fairly basic statistics, and you aren't wedded to the HTTP server concept, use JMX. 如果这些统计信息是相当基本的统计信息的一小部分,并且您不熟悉HTTP服务器的概念,请使用JMX。 I used it to instrument a daemon process and it was pretty simple. 我用它来检测守护进程,这非常简单。 You can monitor remotely (on another computer) via an ugly, but serviceable UI. 您可以通过丑陋但可维护的UI远程(在另一台计算机上)监视。
Here's a tutorial instrumenting a web server app Probably very close to what you want. 这是指导Web服务器应用程序的教程,可能非常接近您想要的内容。
Here's a StackOverflow link on remote monitoring 这是有关远程监控的StackOverflow链接
The lightest weight java webserver I know of is Jetty . 我所知道的最轻量的Java Web服务器是Jetty 。 If you use maven, you don't have to add any dependencies to your project, just add jetty as a plugin: 如果使用maven,则不必向项目添加任何依赖项,只需将jetty添加为插件:
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.26</version>
</plugin>
then you can just call 那你就可以打电话
mvn jetty:run
at the command line. 在命令行中。 a lot of open source projects ship with a jetty server embedded, including hadoop. 许多开放源代码项目都附带嵌入式码头服务器,包括hadoop。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.