簡體   English   中英

如何為彈性beanstalk tomcat提供配置

[英]How do I supply configuration to elastic beanstalk tomcat

在本地部署到tomcat時,我將此更改(如下所示)發送到server.xml,有沒有辦法可以將其提供給Elastic Beanstalk?

<Connector connectionTimeout="20000" port="8080" 
       protocol="org.apache.coyote.http11.Http11NioProtocol" 
       redirectPort="8443"/>'

謝謝 '

您無需提供自定義AMI即可立即執行此操作。 按照以下說明操作: http//aws.typepad.com/aws/2012/10/customize-elastic-beanstalk-using-configuration-files.html

為了在webapp中提供自定義服務器xml create .ebextensions文件夾,請在其中添加自定義server.xml文件並添加一個文件: server-update.config with content:

container_commands:
  replace-config:
  command: cp .ebextensions/server.xml /etc/tomcat7/server.xml

在不替換整個Tomcat server.xml文件的情況下實現此目的的另一種方法是在.ebextensions文件夾中使用以下內容(例如tomcat.config

files:
  "/tmp/update_tomcat_server_xml.sh":
    owner: root
    group: root
    mode: "000755"
    content: |
      #! /bin/bash
      CONFIGURED=`grep -c '<Connector port="8080" URIEncoding="UTF-8"' /etc/tomcat7/server.xml`
      if [ $CONFIGURED = 0 ]
        then
          sed -i 's/Connector port="8080"/Connector port="8080" URIEncoding="UTF-8"/' /etc/tomcat7/server.xml
          logger -t tomcat_conf "/etc/tomcat7/server.xml updated successfully"
          exit 0
        else
          logger -t tomcat_conf "/etc/tomcat7/server.xml already updated"
          exit 0
      fi

container_commands:
  00_update_tomcat_server_xml:
    command: sh /tmp/update_tomcat_server_xml.sh

此配置創建一個腳本( files ),然后運行它( container_command )。 該腳本檢查server.xmlUIREncoding="UTF8"字符串,如果找不到,則使用sed命令將其添加。

這個解決方案的好處是,如果你升級你的Tomcat版本(例如從7升級到8),那么你不必擔心在各種WAR文件中更新server.xml

此外,此示例用於添加UIREncoding參數,但腳本很容易適應從原始問題添加<Connector ... />'屬性。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM