【问题标题】:How can I modify context.xml of Tomcat on aws opsworks?如何在 aws opsworks 上修改 Tomcat 的 context.xml?
【发布时间】:2014-08-02 13:11:10
【问题描述】:

我想在 /usr/share/tomcat7/conf/context.xml 中添加这段代码:

<Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
   sticky="true"
   memcachedNodes="n1:<%= node['redis']['host']%>:<%= node['redis']['port']%>"
   requestUriIgnorePattern=".*.(ico|png|gif|jpg|css|js)$"
/>

我使用的是 Chef 11.4,我创建了自定义说明书并修改了 /opsworks_java/templates/default/webapp_context.xml.erb

但它不起作用。 它适用于其他文件:server.xml!

我该怎么做?

谢谢。

【问题讨论】:

    标签: amazon-web-services chef-recipe aws-opsworks


    【解决方案1】:

    如果您使用的是 Chef 11.10,这很简单:

    1. 您需要创建/使用自定义食谱。

    2. 在其中制作以下文件夹结构:

      opsworks_java/templates/default/

    3. 复制文件: https://github.com/aws/opsworks-cookbooks/blob/release-chef-11.10/opsworks_java/templates/default/webapp_context.xml.erb

    4. 根据需要进行编辑。

    这将完成您需要完成的工作。

    【讨论】:

    • 感谢您的回答。我使用的是 11.4。这正是我所做的,但它不适用于这个文件。我认为 webapp_context.xml.erb 不是生成 context.xml 的脚本!
    【解决方案2】:

    我终于找到了解决方案 我创建了 context.xml 文件的模板: opsworks-cookbooks/opsworks_java/templates/default/context.xml.erb

    <?xml version='1.0' encoding='utf-8'?>
    <Context>
        <!-- Default set of monitored resources -->
        <WatchedResource>WEB-INF/web.xml</WatchedResource>
        <Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
              sticky="true"
              memcachedNodes="n1:<%= node['redis']['host']%>:<%= node['redis']['port']%>"
              requestUriIgnorePattern=".*\.(ico|png|gif|jpg|css|js)$"   />
    </Context>
    

    然后我在 opsworks-cookbooks/opsworks_java/recipes/tomcat_container_config.rb 中调用它 通过添加以下行:

    template 'tomcat context configuration' do
      path ::File.join(node['opsworks_java']['tomcat']['catalina_base_dir'], 'context.xml')
      source 'context.xml.erb'
      owner 'root'
      group 'root'
      mode 0644
      backup false
      notifies :restart, 'service[tomcat]'
    end
    

    而且效果很好!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-02-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-06
      • 2014-08-16
      • 2015-09-17
      • 2015-06-24
      相关资源
      最近更新 更多