<EntryPoint>
<ExeHost>
<Program>java\bin\java.exe</Program>
<Arguments>-Djetty.port=8080 -Djetty.base=..\..\jetty -jar ..\..\jetty\start.jar</Arguments>
<WorkingFolder>CodeBase</WorkingFolder>
<!-- Uncomment to log console output (both stdout and stderr) to one of the
service's working directories. -->
<!-- <ConsoleRedirection FileRetentionCount="5" FileMaxSizeInKb="2048"/> -->
</ExeHost>
</EntryPoint>
其中Program里面我们会调用Java.exe文件,然后在Arguments里面填入Jetty的相关参数,这里要注意的是Program里面不能使用批处理文件,因为Service Fabric的服务监控需要跟踪Exe的进程ID,以便当进程出问题时能够及时切换到其他节点里去。如果你的Program里面指定的是批处理文件.bat的话,虽然这个批处理会执行,但是由于拿不到进程ID,所以Service Fabric会不断的去Call这个批处理的,这也是为什么我选择Jetty而不是常见的Tomcat容器的原因。
编辑好了EntryPoint了,因为jetty是要提供Web服务的,我们需要告诉Service Fabric,这个Application提供的是什么端口服务,所以我们还需要编辑Resources节
<Resources>
<Endpoints>
<!-- This endpoint is used by the communication listener to obtain the port on which to
listen. Please note that if your service is partitioned, this port is shared with
replicas of different partitions that are placed in your code. -->
<Endpoint Name="tomcatTypeEndpoint" Protocol="http" Port="8080" Type="Input" />
</Endpoints>
</Resources>
在Endpoint的设置里面可以看到发布的8080 http端口跟前面一节的参数里面启动Jetty的参数8080是一致的。
做完这些设置,我们再在jetty的webapps的Root里面放入一个index.jsp,以便验证下我们的jetty是不是发布在Service Fabric上的
这个jsp的代码比较简单,就是用来显示下Java版本啥的
<!DOCTYPE html>
<html>
<head>
<title>Microsoft Service Fabric on Java - Welcome</title>
</head>
<body bgcolor="#00abec" >
<div id="feature">
<div id="content">
<h2>Service Fabric on Java,Node Address is:<%out.print(request.getLocalAddr());%></h2>