java 热部署到 Jetty 的最佳解决方案是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/560836/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 12:51:47  来源:igfitidea点击:

What is a best solution for hot deploy to Jetty?

javadeploymentjetty

提问by Vitek

I have a web application which is running on jetty. Continues builds are built on hudson. I would like to make a hot deploy on demand from hudson.

我有一个在码头上运行的网络应用程序。继续构建建立在 hudson 上。我想根据 hudson 的需求进行热部署。

I found cargo plugin which should be able to do so but cargo's web doesn't show any complete example how to do it - for remote jetty server - may be I miss it?

我发现货物插件应该能够做到这一点,但货物的网站没有显示任何完整的示例 - 对于远程码头服务器 - 我可能会错过它吗?

What do you suggest? Do you have any other better solution?

你有什么建议?你有其他更好的解决方案吗?

thank you,

谢谢,

Vitek

维泰克

回答by kazanaki

Cargo's documentationshows that it is possible to deploy to jetty via maven 2.

Cargo 的文档显示可以通过 maven 2 部署到 jetty。

And here is the configuration.

这是配置

I assume you tried this? What was the problem?

我假设你试过这个?出了什么问题?

回答by chetan

Jetty : can be run as as standalone : just remote copy the war you build . Standalone Jetty instances can be run independent ports .

Jetty:可以作为独立运行:只需远程复制您构建的War。独立的 Jetty 实例可以运行独立的端口。

Yml : eg

Yml:例如

<Set name="ThreadPool">
  -->
  <New class="org.mortbay.thread.QueuedThreadPool">
    <Set name="minThreads">10</Set>
    <Set name="maxThreads">50</Set>
    <Set name="lowThreads">5</Set>
    <Set name="SpawnOrShrinkAt">2</Set>
  </New>

</Set>




<Call name="addConnector">
  <Arg>
      <New class="org.mortbay.jetty.nio.SelectChannelConnector">
        <Set name="host"><SystemProperty name="jetty.host" default="0.0.0.0" /></Set>
        <Set name="port"><SystemProperty name="jetty.port" default="8880"/></Set>
        <Set name="maxIdleTime">300000</Set>
        <Set name="Acceptors">2</Set>
        <Set name="statsOn">false</Set>
        <Set name="confidentialPort">8441</Set>
        <Set name="lowResourcesConnections">20000</Set>
        <Set name="lowResourcesMaxIdleTime">5000</Set>
      </New>
  </Arg>
</Call>

<Set name="handler">
  <New id="Handlers" class="org.mortbay.jetty.handler.HandlerCollection">
    <Set name="handlers">
     <Array type="org.mortbay.jetty.Handler">
       <Item>
         <New id="Contexts" class="org.mortbay.jetty.handler.ContextHandlerCollection"/>
       </Item>
       <Item>
         <New id="DefaultHandler" class="org.mortbay.jetty.handler.DefaultHandler"/>
       </Item>
       <Item>
         <New id="RequestLog" class="org.mortbay.jetty.handler.RequestLogHandler"/>
       </Item>
     </Array>
    </Set>
  </New>
</Set>

<Call name="addLifeCycle">
  <Arg>
    <New class="org.mortbay.jetty.deployer.ContextDeployer">
      <Set name="contexts"><Ref id="Contexts"/></Set>
      <Set name="configurationDir"><SystemProperty name="jetty.home" default="."/>/contexts/</Set>
      <Set name="scanInterval">1</Set>
    </New>
  </Arg>
</Call>

<Set name="UserRealms">
  <Array type="org.mortbay.jetty.security.UserRealm">
    <Item>
      <New class="org.mortbay.jetty.security.HashUserRealm">
        <Set name="name">Test Realm</Set>
        <Set name="config"><SystemProperty name="jetty.home" default="."/>/etc/realm.properties</Set>
        <Set name="refreshInterval">0</Set>
      </New>
    </Item>
  </Array>
</Set>

<Ref id="RequestLog">
  <Set name="requestLog">
    <New id="RequestLogImpl" class="org.mortbay.jetty.NCSARequestLog">
      <Set name="filename"><SystemProperty name="jetty.logs" default="./logs"/>/yyyy_mm_dd.request.log</Set>
      <Set name="filenameDateFormat">yyyy_MM_dd</Set>
      <Set name="retainDays">90</Set>
      <Set name="append">true</Set>
      <Set name="extended">true</Set>
      <Set name="logCookies">false</Set>
      <Set name="LogTimeZone">GMT</Set>
    </New>
  </Set>
</Ref>

<Set name="stopAtShutdown">true</Set>
<Set name="sendServerVersion">true</Set>
<Set name="sendDateHeader">true</Set>
<Set name="gracefulShutdown">1000</Set>

回答by somid3

For those of you using Windows, if you run into file locking errors, visit:

对于使用 Windows 的用户,如果遇到文件锁定错误,请访问:

http://docs.codehaus.org/display/JETTY/Files+locked+on+Windows

http://docs.codehaus.org/display/JETTY/Files+locked+on+Windows

Windows locks the files Jetty loads into memory. The above link will show you how to prevent that.

Windows 会锁定 Jetty 加载到内存中的文件。上面的链接将向您展示如何防止这种情况发生。