想要将Jetty设置为热部署,但是没有部署器

发布于 2024-09-26 15:19:37 字数 9219 浏览 9 评论 0原文

我正在运行 SmartFox 1.6 服务器,其中包含 Jetty servlet 容器。我想配置 Jetty 自动部署新的 Web 应用程序。通常,这就像向部署程序添加 scanInterval 一样简单:

<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>

但是,我在 Jetty 配置文件中根本找不到部署程序(粘贴在下面)。该配置是 Smartfox 附带的默认配置。

抱歉需要包含整个配置文件,但我不知道哪些块是相关的。我可以在下面的设置中哪里设置scanInterval

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">

<!-- =============================================================== -->
<!-- Configure the Jetty Server                                      -->
<!-- =============================================================== -->
<Configure id="Server" class="org.mortbay.jetty.Server">

    <!-- =========================================================== -->
    <!-- Server Thread Pool                                          -->
    <!-- =========================================================== -->
    <Set name="ThreadPool">
      <New class="org.mortbay.thread.BoundedThreadPool">
        <Set name="minThreads">10</Set>
        <Set name="lowThreads">50</Set>
        <Set name="maxThreads">250</Set>
      </New>
    </Set>

    <!-- =========================================================== -->
    <!-- Set connectors                                              -->
    <!-- =========================================================== -->
    <!-- One of each type!                                           -->
    <!-- =========================================================== -->

    <!-- Use this connector for many frequently idle connections
         and for threadless continuations.
    -->    
    <Call name="addConnector">
      <Arg>
          <New class="org.mortbay.jetty.nio.SelectChannelConnector">
            <Set name="port"><SystemProperty name="jetty.port" default="8080"/></Set>
            <Set name="maxIdleTime">30000</Set>
            <Set name="Acceptors">2</Set>
            <Set name="confidentialPort">8443</Set>
          </New>
      </Arg>
    </Call>


    <!-- Use this connector if NIO is not available.
    <Call name="addConnector">
      <Arg>
          <New class="org.mortbay.jetty.bio.SocketConnector">
            <Set name="port">8081</Set>
            <Set name="maxIdleTime">50000</Set>
            <Set name="lowResourceMaxIdleTime">1500</Set>
          </New>
      </Arg>
    </Call>
    -->

    <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
    <!-- To add a HTTPS SSL listener                                     -->
    <!-- see jetty-ssl.xml to add an ssl connector. use                  -->
    <!-- java -jar start.jar etc/jetty.xml etc/jetty-ssl.xml             -->
    <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->



    <!-- =========================================================== -->
    <!-- Set handler Collection Structure                            --> 
    <!-- =========================================================== -->
    <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>


    <!-- ======================================================= -->
    <!-- Configure a WebApp                                      -->
    <!-- ======================================================= -->
    <!--
    <New id="TestContext" class="org.mortbay.jetty.webapp.WebAppContext">
      <Arg><Ref id="contexts"/></Arg>
      <Arg><SystemProperty name="jetty.home" default="."/>/webapps/test</Arg>
      <Arg>/</Arg>
      <Set name="classLoader">
        <New class="org.mortbay.jetty.webapp.TransformingWebAppClassLoader">
          <Arg><Ref id="TestContext"/></Arg>
        </New>
      </Set>
      <Set name="defaultsDescriptor"><SystemProperty name="jetty.home" default="."/>/etc/webdefault.xml</Set>
      <Set name="virtualHosts">
        <Array type="java.lang.String">
          <Item>localhost</Item>
        </Array>
      </Set>

      <Get name="SessionHandler">
        <Set name="SessionManager">
          <New class="org.mortbay.jetty.servlet.HashSessionManager">
            <Set name="maxInactiveInterval">600</Set>
          </New>
        </Set>
      </Get>
    </New>
    -->

    <!-- ======================================================= -->
    <!-- Configure a Context                                     -->
    <!-- ======================================================= -->
    <New class="org.mortbay.jetty.servlet.Context">
      <Arg><Ref id="contexts"/></Arg>
      <Arg>/javadoc</Arg>
      <Set name="resourceBase"><SystemProperty name="jetty.home" default="."/>/javadoc/</Set>
      <Call name="addServlet">
        <Arg>org.mortbay.jetty.servlet.DefaultServlet</Arg>
        <Arg>/</Arg>
      </Call>
    </New>

    <!-- =========================================================== -->
    <!-- Discover contexts from webapps directory                    -->
    <!-- =========================================================== -->
    <Call class="org.mortbay.jetty.webapp.WebAppContext" name="addWebApplications">
      <Arg><Ref id="contexts"/></Arg>
      <Arg><SystemProperty name="jetty.home" default="."/>/webserver/webapps</Arg>
      <Arg><SystemProperty name="jetty.home" default="."/>/webserver/cfg/webdefault.xml</Arg>
      <Arg type="boolean">True</Arg>  <!-- extract -->
      <Arg type="boolean">False</Arg> <!-- parent priority class loading -->
    </Call>

    <!-- =========================================================== -->
    <!-- Configure Realms                                            -->
    <!-- =========================================================== -->
    <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="."/>/webserver/cfg/realm.properties</Set>
          </New>
        </Item>
      </Array>
    </Set>


    <!-- =========================================================== -->
    <!-- Configure Request Log                                       -->
    <!-- =========================================================== -->
    <Ref id="requestLog">
      <Set name="requestLog">
        <New id="requestLogImpl" class="org.mortbay.jetty.NCSARequestLog">
          <Arg><SystemProperty name="jetty.logs" default="./logs"/>/yyyy_mm_dd.request.log</Arg>
          <Set name="retainDays">90</Set>
          <Set name="append">true</Set>
          <Set name="extended">false</Set>
          <Set name="LogTimeZone">GMT</Set>
        </New>
      </Set>
    </Ref>

    <!-- =========================================================== -->
    <!-- extra options                                               -->
    <!-- =========================================================== -->
    <Set name="stopAtShutdown">true</Set>
    <!-- ensure/prevent Server: header being sent to browsers        -->
    <Set name="sendServerVersion">true</Set>

</Configure>

I'm running a SmartFox 1.6 server with included Jetty servlet container. I want to configure Jetty to automatically deploy new web apps. Normally this is as simple as adding a scanInterval to the deployer:

<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>

However, I can't find a deployer at all in the Jetty config file, pasted below. The config is the default config included with Smartfox.

Sorry for needing to include the entire config file, but I wouldn't know which blocks are relevant. Where can I set the scanInterval in the settings below?

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">

<!-- =============================================================== -->
<!-- Configure the Jetty Server                                      -->
<!-- =============================================================== -->
<Configure id="Server" class="org.mortbay.jetty.Server">

    <!-- =========================================================== -->
    <!-- Server Thread Pool                                          -->
    <!-- =========================================================== -->
    <Set name="ThreadPool">
      <New class="org.mortbay.thread.BoundedThreadPool">
        <Set name="minThreads">10</Set>
        <Set name="lowThreads">50</Set>
        <Set name="maxThreads">250</Set>
      </New>
    </Set>

    <!-- =========================================================== -->
    <!-- Set connectors                                              -->
    <!-- =========================================================== -->
    <!-- One of each type!                                           -->
    <!-- =========================================================== -->

    <!-- Use this connector for many frequently idle connections
         and for threadless continuations.
    -->    
    <Call name="addConnector">
      <Arg>
          <New class="org.mortbay.jetty.nio.SelectChannelConnector">
            <Set name="port"><SystemProperty name="jetty.port" default="8080"/></Set>
            <Set name="maxIdleTime">30000</Set>
            <Set name="Acceptors">2</Set>
            <Set name="confidentialPort">8443</Set>
          </New>
      </Arg>
    </Call>


    <!-- Use this connector if NIO is not available.
    <Call name="addConnector">
      <Arg>
          <New class="org.mortbay.jetty.bio.SocketConnector">
            <Set name="port">8081</Set>
            <Set name="maxIdleTime">50000</Set>
            <Set name="lowResourceMaxIdleTime">1500</Set>
          </New>
      </Arg>
    </Call>
    -->

    <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
    <!-- To add a HTTPS SSL listener                                     -->
    <!-- see jetty-ssl.xml to add an ssl connector. use                  -->
    <!-- java -jar start.jar etc/jetty.xml etc/jetty-ssl.xml             -->
    <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->



    <!-- =========================================================== -->
    <!-- Set handler Collection Structure                            --> 
    <!-- =========================================================== -->
    <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>


    <!-- ======================================================= -->
    <!-- Configure a WebApp                                      -->
    <!-- ======================================================= -->
    <!--
    <New id="TestContext" class="org.mortbay.jetty.webapp.WebAppContext">
      <Arg><Ref id="contexts"/></Arg>
      <Arg><SystemProperty name="jetty.home" default="."/>/webapps/test</Arg>
      <Arg>/</Arg>
      <Set name="classLoader">
        <New class="org.mortbay.jetty.webapp.TransformingWebAppClassLoader">
          <Arg><Ref id="TestContext"/></Arg>
        </New>
      </Set>
      <Set name="defaultsDescriptor"><SystemProperty name="jetty.home" default="."/>/etc/webdefault.xml</Set>
      <Set name="virtualHosts">
        <Array type="java.lang.String">
          <Item>localhost</Item>
        </Array>
      </Set>

      <Get name="SessionHandler">
        <Set name="SessionManager">
          <New class="org.mortbay.jetty.servlet.HashSessionManager">
            <Set name="maxInactiveInterval">600</Set>
          </New>
        </Set>
      </Get>
    </New>
    -->

    <!-- ======================================================= -->
    <!-- Configure a Context                                     -->
    <!-- ======================================================= -->
    <New class="org.mortbay.jetty.servlet.Context">
      <Arg><Ref id="contexts"/></Arg>
      <Arg>/javadoc</Arg>
      <Set name="resourceBase"><SystemProperty name="jetty.home" default="."/>/javadoc/</Set>
      <Call name="addServlet">
        <Arg>org.mortbay.jetty.servlet.DefaultServlet</Arg>
        <Arg>/</Arg>
      </Call>
    </New>

    <!-- =========================================================== -->
    <!-- Discover contexts from webapps directory                    -->
    <!-- =========================================================== -->
    <Call class="org.mortbay.jetty.webapp.WebAppContext" name="addWebApplications">
      <Arg><Ref id="contexts"/></Arg>
      <Arg><SystemProperty name="jetty.home" default="."/>/webserver/webapps</Arg>
      <Arg><SystemProperty name="jetty.home" default="."/>/webserver/cfg/webdefault.xml</Arg>
      <Arg type="boolean">True</Arg>  <!-- extract -->
      <Arg type="boolean">False</Arg> <!-- parent priority class loading -->
    </Call>

    <!-- =========================================================== -->
    <!-- Configure Realms                                            -->
    <!-- =========================================================== -->
    <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="."/>/webserver/cfg/realm.properties</Set>
          </New>
        </Item>
      </Array>
    </Set>


    <!-- =========================================================== -->
    <!-- Configure Request Log                                       -->
    <!-- =========================================================== -->
    <Ref id="requestLog">
      <Set name="requestLog">
        <New id="requestLogImpl" class="org.mortbay.jetty.NCSARequestLog">
          <Arg><SystemProperty name="jetty.logs" default="./logs"/>/yyyy_mm_dd.request.log</Arg>
          <Set name="retainDays">90</Set>
          <Set name="append">true</Set>
          <Set name="extended">false</Set>
          <Set name="LogTimeZone">GMT</Set>
        </New>
      </Set>
    </Ref>

    <!-- =========================================================== -->
    <!-- extra options                                               -->
    <!-- =========================================================== -->
    <Set name="stopAtShutdown">true</Set>
    <!-- ensure/prevent Server: header being sent to browsers        -->
    <Set name="sendServerVersion">true</Set>

</Configure>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

无远思近则忧 2024-10-03 15:19:37

您只需将此调用添加到您的配置文件中即可。

you just need to add this Call to your config file.

星光不落少年眉 2024-10-03 15:19:37

在这里回答,以防有人遇到这个线程。 jetty 中可以进行热部署,您需要在 jetty ini 文件中指定间隔、位置等,而不是在 jetty-xml 中。请参阅下面的官方码头文档
https://www.eclipse.org/jetty/documentation/current/热部署.html

Answering it here, in case anyone come across this thread. Hot deployment is possible in jetty, you need to specify interval, location etc. in jetty ini files, not in jetty-xmls. See below official jetty documentations
https://www.eclipse.org/jetty/documentation/current/hot-deployment.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文