惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

美团技术团队
博客园_首页
量子位
F
Fortinet All Blogs
L
LangChain Blog
The Cloudflare Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
大猫的无限游戏
大猫的无限游戏
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
V
Visual Studio Blog
Blog — PlanetScale
Blog — PlanetScale
博客园 - 叶小钗
Apple Machine Learning Research
Apple Machine Learning Research
博客园 - Franky
G
Google Developers Blog
阮一峰的网络日志
阮一峰的网络日志
T
Tailwind CSS Blog
WordPress大学
WordPress大学
宝玉的分享
宝玉的分享
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
有赞技术团队
有赞技术团队
U
Unit 42
IT之家
IT之家

方永、南天紫雲

linux透明代理 技术的边界 停机问题通俗说明 Rust与oracle、redis集群的纠结 学习能力的增长 微信调试的原语 mac外接移动硬盘安装ArchLinux linux的死机问题 linux下全键盘操作 漂亮又好用的bspwm linux本机透明代理 ssh、mosh、autossh linux不能待机又一例 从WordPress切换到Hugo 折腾电脑开机 linux系统QQ新思路 Arch Linux的字体渲染 svn管理之submin OpenWrt自动fucking墙記錄 二维码(qrcode)名片的一些事儿 用lua nginx module搭建一个二维码(qr code)生成器 CentOS 7 安裝註記 php程序連接MySQL时只能127.0.0.1而localhost無法連接的問題 ThinkPad之FAN_ERROR、hi fi聲卡 OpenWrt簡單暴力限網 linux中cron之PATH变量 OpenWrt的WDS無線橋接模式 再敘OpenWrt下的rtl8187無線中繼 sed之模擬tail 終端進化之二零一三
jetty多端口部署
zola · 2014-05-12 · via 方永、南天紫雲

有时需要将多个项目归并在同一个jetty下面部署,節省資源,便於管理。下面是部署過程:

僅在jetty 8.1.15測試通過,jetty9以上版本由於xml格式變動,需要做一些修改

一、 在 webapps 及 contexts 下面各新建目錄 1,2,3,4 ,在jetty的 etc 中添加 jetty2.xml 、 jetty3.xml 、 jetty4.xml 文件,內容如下:

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
<Configure id="Server2" class="org.eclipse.jetty.server.Server">
 
<Set name="ThreadPool">
     <!-- Default queued blocking threadpool -->
     <New class="org.eclipse.jetty.util.thread.QueuedThreadPool">
       <Set name="minThreads">10</Set>
       <Set name="maxThreads">200</Set>
       <Set name="detailedDump">false</Set>
     </New>
</Set>
 
<Call name="setAttribute">
     <Arg>org.eclipse.jetty.webapp.configuration</Arg>
     <Arg>
         <Array type="java.lang.String">
              <Item>org.eclipse.jetty.webapp.WebInfConfiguration</Item>
              <Item>org.eclipse.jetty.webapp.WebXmlConfiguration</Item>
              <Item>org.eclipse.jetty.webapp.MetaInfConfiguration</Item>
              <Item>org.eclipse.jetty.webapp.FragmentConfiguration</Item>
              <Item>org.eclipse.jetty.annotations.AnnotationConfiguration</Item>
              <Item>org.eclipse.jetty.webapp.JettyWebXmlConfiguration</Item>
         </Array>
     </Arg>
 </Call>
 
 
<Set name="handler">
      <New id="Handlers2" class="org.eclipse.jetty.server.handler.HandlerCollection">
        <Set name="handlers">
         <Array type="org.eclipse.jetty.server.Handler">
           <Item>
             <New id="Contexts2" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
           </Item>
         </Array>
        </Set>
      </New>
 </Set>
 
 
 
 <Call name="addConnector">
      <Arg>
          <New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
            <Set name="host"><Property name="jetty.host" /></Set>
            <Set name="port"><Property name="jetty.port" default="8010"/></Set>
            <Set name="maxIdleTime">300000</Set>
            <Set name="Acceptors">2</Set>
            <Set name="statsOn">false</Set>
            <Set name="confidentialPort">8443</Set>
        <Set name="lowResourcesConnections">20000</Set>
        <Set name="lowResourcesMaxIdleTime">5000</Set>
          </New>
      </Arg>
  </Call>
 
 
  <Call name="addBean">
    <Arg>
      <New id="DeploymentManager" class="org.eclipse.jetty.deploy.DeploymentManager">
        <Set name="contexts">
          <Ref id="Contexts2" />
        </Set>
          <Call id="webappprovider" name="addAppProvider">
            <Arg>
              <New class="org.eclipse.jetty.deploy.providers.WebAppProvider">
                <Set name="monitoredDirName"><Property name="jetty.home" default="." />/webapps/2</Set>
                <Set name="defaultsDescriptor"><Property name="jetty.home" default="."/>/etc/webdefault.xml</Set>
                <Set name="scanInterval">1</Set>
                <Set name="contextXmlDir"><Property name="jetty.home" default="." />/contexts/2</Set>
              </New>
            </Arg>
          </Call>
          <Call name="addAppProvider">
             <Arg>
               <New class="org.eclipse.jetty.deploy.providers.ContextProvider">
                 <Set name="monitoredDirName"><Property name="jetty.home" default="." />/contexts/2</Set>
                 <Set name="scanInterval">1</Set>
               </New>
             </Arg>
          </Call>
 
      </New>
    </Arg>
  </Call>
 
</Configure>

修改相對目錄及端口號。

二、 更改 jetty-webapps.xml 、 jetty-contexts.xml 的相對目錄,如 monitoredDirName 的值改爲 /webapps/1 。

三、添加或修改 contexts 中 1,2,3,4 中項目的配置文件,內容可如下:

<?xml version="1.0"  encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
 
  <Set name="contextPath">/</Set>
  <Set name="war"><SystemProperty name="jetty.home" default="."/>/webapps/4/root</Set>
 
  <Set name="extractWAR">true</Set>
  <Set name="copyWebDir">false</Set>
  <Set name="defaultsDescriptor"><SystemProperty name="jetty.home" default="."/>/etc/webdefault.xml</Set>
 
</Configure>

四、 在 etc/jetty.conf 中添加如下内容:

etc/jetty2.xml
etc/jetty3.xml
etc/jetty4.xml

五、 启动jetty。