在码头管理员的文档中,-stats标志将允许在http://localhost/stats下显示统计信息.但是AFAICT是任何其他接口都无法使用的,我看不出有什么方法可以配置它。
有没有一种向网络开放/stats的方法?
以下是详细信息:
启动jetty,运行恶心的战争,开着"stats“,没有密码,没有任何主机标志。
$ java -jar jetty-runner-9.2.3.v20140905.jar --stats unsecure grobid-service-0.2.10.war &
[10] 29549
$ 2014-11-07 09:07:31.255:INFO::main: Logging initialized @47ms
2014-11-07 09:07:31.261:INFO:oejr.Runner:main: Runner
2014-11-07 09:07:31.383:INFO:oejs.Server:main: jetty-9.2.3.v20140905
2014-11-07 09:07:31.416:INFO:oejsh.ContextHandler:main: Started o.e.j.s.ServletContextHandler@6981170d{/stats,null,AVAILABLE}
Nov 07, 2014 9:07:33 AM com.sun.jersey.api.core.PackagesResourceConfig init
INFO: Scanning for root resource and provider classes in the packages:
org.grobid.service
Nov 07, 2014 9:07:33 AM com.sun.jersey.api.core.ScanningResourceConfig logClasses
INFO: Root resource classes found:
class org.grobid.service.GrobidRestService
Nov 07, 2014 9:07:33 AM com.sun.jersey.api.core.ScanningResourceConfig init
INFO: No provider classes found.
Nov 07, 2014 9:07:33 AM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFO: Initiating Jersey application, version 'Jersey: 1.9 09/02/2011 11:17 AM'
2014-11-07 09:07:35.160:INFO:oejsh.ContextHandler:main: Started o.e.j.w.WebAppContext@1a108c98{/,file:/tmp/jetty-0.0.0.0-8080-grobid-service-0.2.10.war-_-any-6704428208347840300.dir/webapp/,AVAILABLE}{file:/home/kevin/temp/xx/grobid-service-0.2.10.war}
2014-11-07 09:07:35.161:WARN:oejsh.RequestLogHandler:main: !RequestLog
2014-11-07 09:07:35.180:INFO:oejs.ServerConnector:main: Started ServerConnector@10a54c39{HTTP/1.1}{0.0.0.0:8080}
2014-11-07 09:07:35.180:INFO:oejs.Server:main: Started @3998ms我可以从外部网络接口请求不良服务,没有问题。
$ wget -qS 'http://192.168.122.171:8080' -O - | head -5
HTTP/1.1 200 OK
Date: Fri, 07 Nov 2014 17:10:19 GMT
Accept-Ranges: bytes
Content-Type: text/html
Last-Modified: Tue, 04 Nov 2014 21:03:04 GMT
Content-Length: 7772
Server: Jetty(9.2.3.v20140905)
<!DOCTYPE XHTML>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Grobid Web Application</title>但是,"/stats/“是该接口上不可用的503-服务
$ wget -qS 'http://192.168.122.171:8080/stats/' -O - | head -5
HTTP/1.1 503 Service Unavailable
Date: Fri, 07 Nov 2014 17:11:41 GMT
Cache-Control: must-revalidate,no-cache,no-store
Content-Type: text/html; charset=ISO-8859-1
Content-Length: 294
Server: Jetty(9.2.3.v20140905)虽然本地主机上有"/stats/“
$ wget -qS 'http://127.0.0.1:8080/stats/' -O - | head -5
HTTP/1.1 200 OK
Date: Fri, 07 Nov 2014 17:15:30 GMT
Content-Type: text/html; charset=ISO-8859-1
Content-Length: 1342
Server: Jetty(9.2.3.v20140905)
<h1>Statistics:</h1>
Statistics gathering started 9185ms ago<br />
<h2>Requests:</h2>
Total requests: 3<br />
Active requests: 1<br />针对Joakim Erdfelt的以下建议,添加-主机0.0.0.0或-主机192.168.122.171如下
java -jar jetty-runner-9.2.3.v20140905.jar --host 192.168.122.171 --stats unsecure grobid-service-0.2.10.war &仍然导致503-服务不可用。我知道--host 192.168.122.171有一定的效果,因为在127.0.0.1查询时,/的工作页面是不可用的。
发布于 2016-04-02 23:22:35
如果有人将面临与@KevinG是我的解决方案相同的问题,因为我发现这个主题试图解决相同的问题,经过一段时间的思考,我找到了如何克服这个限制的方法,即只能在本地调用数据,这是在机器/服务器上运行的。
首先将nginx安装在您正在运行的同一台服务器/机器上。确保在nginx中使用代理转发将所有流量转发给抛出运行者(localhost:8080)。默认情况下,nginx应该侦听端口80。从您的主机服务器/机器/本地pc打开http://localhost:80,nginx将将您的请求转发给抛出运行者并返回回复。同样适用于/stats/。在您的主机/本地pc上打开http://localhost:80/stats/,您将到达码头跑步者的统计页面。
nginx配置:
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html index.htm;
## default location ##
location / {
access_log off;
proxy_pass http://localhost:8080;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}发布于 2014-11-07 14:11:04
当您使用jetty-runner命令启用统计信息时,实际上是在将一个StatisticsHandler添加到正在运行的服务器及其所有连接器中。
现在,使用jetty-runner,您只有一个连接器,您可以通过命令行控制它的侦听--port和--host。
如果您只指定了--host localhost,那么它将只收集本地主机接口的统计信息。
如果您想让它监听所有接口,那么就使用类似于--host 0.0.0.0的东西来侦听所有的IPv4接口(如果使用IPv6,则必须使用IPv6等效)
https://stackoverflow.com/questions/26791966
复制相似问题