Successfully reported this slideshow.
Masters of WAR
    Mark Stanton
    @MarkStanto
Warning
Warning

•   Don’t try this at home
Warning

•   Don’t try this at home
Warning

•   Don’t try this at home


•   Unless you:
    •   have a lot of time and patience
    •   understand support/l...
What we’ll cover


•   Ant
•   WAR
•   JRun
Apache Ant


•   Automated build system
•   Java based
•   XML configuration
Why Automated Builds?


•   Repeatable
•   Predictable
•   Scalable
Why Ant?
Why Ant?
•   Familiar
    •   Java
    •   Eclipse
    •   XML
    •   SSH/HTTP
Why Ant?
•   Familiar
    •   Java
    •   Eclipse
    •   XML
    •   SSH/HTTP
•   Hackable
Example: Deploying
   Hello World
Example: Deploying
   Hello World

             •   <project>
Example: Deploying
   Hello World

             •   <project>
             •   <target>
Example: Deploying
   Hello World

             •   <project>
             •   <target>
             •   Tasks:
          ...
Example: Depolying
   Mango Blog
Example: Depolying
   Mango Blog

            •   <property>
Example: Depolying
   Mango Blog

            •   <property>
            •   depends=“ ”
Example: Depolying
   Mango Blog

            •   <property>
            •   depends=“ ”
            •   Tasks:
          ...
Example: Depolying
   Mango Blog
Example: Depolying
   Mango Blog



             •   Tasks:
                 •   <delete>
                 •   <fileset>
Web Application
  aRchives
Web Application
         aRchives
“JAR file used to distribute a collection of JavaServer
Pages, servlets, Java classes, XM...
Web Application
  aRchives
Web Application
  aRchives
Web Application
        aRchives
•   Special kind of JAR (which is a special ZIP)
Web Application
        aRchives
•   Special kind of JAR (which is a special ZIP)
•   Directory structure (compressed or n...
Example: Creating a
      WAR
Example: Manually
Deploying a WAR
JRun
JRun

•   Hackable / Configurable
    •   XML files
    •   Properties files
JRun

•   Hackable / Configurable
    •   XML files
    •   Properties files
•   Versionable
JRun

•   Hackable / Configurable
    •   XML files
    •   Properties files
•   Versionable
•   Deployable
JRun

•   Hackable / Configurable
    •   XML files
    •   Properties files
•   Versionable
•   Deployable


               ...
JRun Architecture

website   website             website        website                     Sites



                     ...
JRun Architecture

website          website             website        website                     Sites



              ...
Sandboxing

 Website       Website       Website         Website                       Sites



                          ...
Mixed Purpose

Mango         A          B    Mango         A            B                     Sites



                   ...
Memory Allocation

Mango         A          B   Mango         A            B                         Sites



            ...
JRun Architecture

Mango         A          B   Mango         A            B                         Apache Virtuals



  ...
JRun Architecture

Mango         A          B   Mango         A            B


                                           ...
JRun Configuration
JRun Configuration
•   {jrun}/lib/servers.xml
    •   Which servers are configured?
    •   Where does each server live?
Server Configuration
Server Configuration
•   {jrun}/bin/jvm.config
    •   Path to JRE
    •   VM args - memory, GC
    •   Classpath
Server Configuration
•   {jrun}/bin/jvm.config
    •   Path to JRE
    •   VM args - memory, GC
    •   Classpath
•   Can ha...
Server Configuration
Server Configuration
•   {server}/SERVER-INF/jrun.xml
    •   Metrics & logging
    •   Deploy directory
    •   HTTP WebSe...
Server Configuration
•   {server}/SERVER-INF/jrun.xml
    •   Metrics & logging
    •   Deploy directory
    •   HTTP WebSe...
Server Configuration
Server Configuration
•   {server}/SERVER-INF/jndi.properties
    •   Java Naming Service (JNDI) port
    •   Used for clust...
Application
Configuration
Application
            Configuration
•   {app-name}/WEB-INF/jrun-web.xml
    •   <context-root>/</context-root> is missing...
Application
Configuration
Application
            Configuration
•   {app}/WEB-INF/cfusion/lib/neo-*.xml
    •   All settings for CF Administrator
   ...
Creating a new server
Creating a new server
Creating a new server
Creating a new server
Creating a new server
Creating a new server

•   Creates /opt/jrun4/servers/deploy containing
Creating a new server

•   Creates /opt/jrun4/servers/deploy containing
    •   default-ear
Creating a new server

•   Creates /opt/jrun4/servers/deploy containing
    •   default-ear
    •   SERVER-INF
Creating a new server

•   Creates /opt/jrun4/servers/deploy containing
    •   default-ear
    •   SERVER-INF
•   Delete ...
Creating a new server
•   Point Apache at the new server
WAR Deployment uses
       Ant
Integrating with our
        build
Example: Deploying a
       WAR
Example: Deploying a
       WAR
Example: Deploying a
           WAR

•   <antcall>
Example: Deploying a
           WAR

•   <antcall>
•   <sleep>
Example: Deploying a
           WAR

•   <antcall>
•   <sleep>
•   <war>
Recap
Recap

•   Created empty JRun server
Recap

•   Created empty JRun server
•   Created WAR containing empty CF instance
Recap

•   Created empty JRun server
•   Created WAR containing empty CF instance
•   Integrated with Ant build
Recap

•   Created empty JRun server
•   Created WAR containing empty CF instance
•   Integrated with Ant build
•   Deploy...
Why bother?
Cons
Cons


•   Up front cost
Cons


•   Up front cost
•   Longer build time
Pros
Pros

•   Save time
Pros

•   Save time
•   Prevent errors & inconsistencies
Pros

•   Save time
•   Prevent errors & inconsistencies
•   Versioning of config & dependencies
Pros

•   Save time
•   Prevent errors & inconsistencies
•   Versioning of config & dependencies
•   Easy to scale
Pros

•   Save time
•   Prevent errors & inconsistencies
•   Versioning of config & dependencies
•   Easy to scale
•   Good...
Make up your own mind
Other uses for Ant
Other uses for Ant
•   Checkout from version control / Tag revision
Other uses for Ant
•   Checkout from version control / Tag revision
•   Minify & combine JS
Other uses for Ant
•   Checkout from version control / Tag revision
•   Minify & combine JS
•   Run database update scripts
Other uses for Ant
•   Checkout from version control / Tag revision
•   Minify & combine JS
•   Run database update script...
Other uses for Ant
•   Checkout from version control / Tag revision
•   Minify & combine JS
•   Run database update script...
Other uses for Ant
•   Checkout from version control / Tag revision
•   Minify & combine JS
•   Run database update script...
Extending Ant
Extending Ant


•   Custom tasks
Extending Ant


•   Custom tasks
•   If you can do it in Java, you can do it in Ant
Extending Ant


•   Custom tasks
•   If you can do it in Java, you can do it in Ant
•   Someone probably already has
Questions?
Upcoming SlideShare
Loading in …5
×

Masters of WAR

1,371 views

Published on

Example build files are available at http://mark.gruden.com/masters-of-war-build-files.zip

Mark walks though how to create a scalable and automated deployment process for Coldfusion apps using Ant. Starting with some reverse engineering of CF's built-in WAR deployment process, we'll then be working through to the separation of application code, the CF runtime and CF's configuration files into distinct elements that can be versioned independently and finally looking at how these assets can be deployed selectively to a number of servers and put back together into running applications.

Published in: Technology
  • Be the first to like this

Masters of WAR

  1. 1. Masters of WAR Mark Stanton @MarkStanto
  2. 2. Warning
  3. 3. Warning • Don’t try this at home
  4. 4. Warning • Don’t try this at home
  5. 5. Warning • Don’t try this at home • Unless you: • have a lot of time and patience • understand support/license implications
  6. 6. What we’ll cover • Ant • WAR • JRun
  7. 7. Apache Ant • Automated build system • Java based • XML configuration
  8. 8. Why Automated Builds? • Repeatable • Predictable • Scalable
  9. 9. Why Ant?
  10. 10. Why Ant? • Familiar • Java • Eclipse • XML • SSH/HTTP
  11. 11. Why Ant? • Familiar • Java • Eclipse • XML • SSH/HTTP • Hackable
  12. 12. Example: Deploying Hello World
  13. 13. Example: Deploying Hello World • <project>
  14. 14. Example: Deploying Hello World • <project> • <target>
  15. 15. Example: Deploying Hello World • <project> • <target> • Tasks: • <echo> • <scp>
  16. 16. Example: Depolying Mango Blog
  17. 17. Example: Depolying Mango Blog • <property>
  18. 18. Example: Depolying Mango Blog • <property> • depends=“ ”
  19. 19. Example: Depolying Mango Blog • <property> • depends=“ ” • Tasks: • <zip> • <sshexec>
  20. 20. Example: Depolying Mango Blog
  21. 21. Example: Depolying Mango Blog • Tasks: • <delete> • <fileset>
  22. 22. Web Application aRchives
  23. 23. Web Application aRchives “JAR file used to distribute a collection of JavaServer Pages, servlets, Java classes, XML files, tag libraries and static Web pages (HTML and related files) that together constitute a Web application.” http://en.wikipedia.org/wiki/WAR_(Sun_file_format)
  24. 24. Web Application aRchives
  25. 25. Web Application aRchives
  26. 26. Web Application aRchives • Special kind of JAR (which is a special ZIP)
  27. 27. Web Application aRchives • Special kind of JAR (which is a special ZIP) • Directory structure (compressed or not)
  28. 28. Example: Creating a WAR
  29. 29. Example: Manually Deploying a WAR
  30. 30. JRun
  31. 31. JRun • Hackable / Configurable • XML files • Properties files
  32. 32. JRun • Hackable / Configurable • XML files • Properties files • Versionable
  33. 33. JRun • Hackable / Configurable • XML files • Properties files • Versionable • Deployable
  34. 34. JRun • Hackable / Configurable • XML files • Properties files • Versionable • Deployable http://gizmodo.com/5073637/fanboy-fever-explained-through-science
  35. 35. JRun Architecture website website website website Sites JRun Management cfusion-ear/cfusion-war WAR/EAR Applications Console cfusion admin J2EE Server Jrun Installation
  36. 36. JRun Architecture website website website website Sites example- JRun Management cfusion-ear/cfusion-war WAR/EAR Applications war Console cfusion admin J2EE Server Jrun Installation
  37. 37. Sandboxing Website Website Website Website Sites JRun Management cfusion-ear cfusion-ear cfusion-ear cfusion-ear WAR/EAR Applications Console client 1 client 2 client 3 client 4 admin J2EE Server Jrun Installation
  38. 38. Mixed Purpose Mango A B Mango A B Sites JRun Management Blog Apps Blog Apps WAR/EAR Applications Console staging production admin J2EE Server Jrun Installation
  39. 39. Memory Allocation Mango A B Mango A B Sites JRun Management Blog Apps Blog Apps WAR/EAR Applications Console staging production admin J2EE Server 500MB 1GB 200MB Jrun Installation
  40. 40. JRun Architecture Mango A B Mango A B Apache Virtuals JRun Management Blog Apps Blog Apps Instances of Coldfusion Console staging production admin JVM instances 500MB 1GB 200MB Jrun Installation
  41. 41. JRun Architecture Mango A B Mango A B jrun-web.xml JRun Management Blog Apps Blog Apps license.properies Console neo-*.xml jvm.config staging production admin jrun.xml jndi.properties 500MB 1GB 200MB Jrun Installation servers.xml
  42. 42. JRun Configuration
  43. 43. JRun Configuration • {jrun}/lib/servers.xml • Which servers are configured? • Where does each server live?
  44. 44. Server Configuration
  45. 45. Server Configuration • {jrun}/bin/jvm.config • Path to JRE • VM args - memory, GC • Classpath
  46. 46. Server Configuration • {jrun}/bin/jvm.config • Path to JRE • VM args - memory, GC • Classpath • Can have one per server
  47. 47. Server Configuration
  48. 48. Server Configuration • {server}/SERVER-INF/jrun.xml • Metrics & logging • Deploy directory • HTTP WebService & ProxyService ports
  49. 49. Server Configuration • {server}/SERVER-INF/jrun.xml • Metrics & logging • Deploy directory • HTTP WebService & ProxyService ports • Beware of port conflicts
  50. 50. Server Configuration
  51. 51. Server Configuration • {server}/SERVER-INF/jndi.properties • Java Naming Service (JNDI) port • Used for clustering
  52. 52. Application Configuration
  53. 53. Application Configuration • {app-name}/WEB-INF/jrun-web.xml • <context-root>/</context-root> is missing by default • Applications run under /{app-name}
  54. 54. Application Configuration
  55. 55. Application Configuration • {app}/WEB-INF/cfusion/lib/neo-*.xml • All settings for CF Administrator • Caching, Memory, Verity, Data Sources, Mail, etc
  56. 56. Creating a new server
  57. 57. Creating a new server
  58. 58. Creating a new server
  59. 59. Creating a new server
  60. 60. Creating a new server
  61. 61. Creating a new server • Creates /opt/jrun4/servers/deploy containing
  62. 62. Creating a new server • Creates /opt/jrun4/servers/deploy containing • default-ear
  63. 63. Creating a new server • Creates /opt/jrun4/servers/deploy containing • default-ear • SERVER-INF
  64. 64. Creating a new server • Creates /opt/jrun4/servers/deploy containing • default-ear • SERVER-INF • Delete default-ear application
  65. 65. Creating a new server • Point Apache at the new server
  66. 66. WAR Deployment uses Ant
  67. 67. Integrating with our build
  68. 68. Example: Deploying a WAR
  69. 69. Example: Deploying a WAR
  70. 70. Example: Deploying a WAR • <antcall>
  71. 71. Example: Deploying a WAR • <antcall> • <sleep>
  72. 72. Example: Deploying a WAR • <antcall> • <sleep> • <war>
  73. 73. Recap
  74. 74. Recap • Created empty JRun server
  75. 75. Recap • Created empty JRun server • Created WAR containing empty CF instance
  76. 76. Recap • Created empty JRun server • Created WAR containing empty CF instance • Integrated with Ant build
  77. 77. Recap • Created empty JRun server • Created WAR containing empty CF instance • Integrated with Ant build • Deployed WAR into JRun server along with CF code
  78. 78. Why bother?
  79. 79. Cons
  80. 80. Cons • Up front cost
  81. 81. Cons • Up front cost • Longer build time
  82. 82. Pros
  83. 83. Pros • Save time
  84. 84. Pros • Save time • Prevent errors & inconsistencies
  85. 85. Pros • Save time • Prevent errors & inconsistencies • Versioning of config & dependencies
  86. 86. Pros • Save time • Prevent errors & inconsistencies • Versioning of config & dependencies • Easy to scale
  87. 87. Pros • Save time • Prevent errors & inconsistencies • Versioning of config & dependencies • Easy to scale • Good discipline
  88. 88. Make up your own mind
  89. 89. Other uses for Ant
  90. 90. Other uses for Ant • Checkout from version control / Tag revision
  91. 91. Other uses for Ant • Checkout from version control / Tag revision • Minify & combine JS
  92. 92. Other uses for Ant • Checkout from version control / Tag revision • Minify & combine JS • Run database update scripts
  93. 93. Other uses for Ant • Checkout from version control / Tag revision • Minify & combine JS • Run database update scripts • Run unit tests
  94. 94. Other uses for Ant • Checkout from version control / Tag revision • Minify & combine JS • Run database update scripts • Run unit tests • Send notification email/SMS
  95. 95. Other uses for Ant • Checkout from version control / Tag revision • Minify & combine JS • Run database update scripts • Run unit tests • Send notification email/SMS • Continuous integration / scheduled builds
  96. 96. Extending Ant
  97. 97. Extending Ant • Custom tasks
  98. 98. Extending Ant • Custom tasks • If you can do it in Java, you can do it in Ant
  99. 99. Extending Ant • Custom tasks • If you can do it in Java, you can do it in Ant • Someone probably already has
  100. 100. Questions?

×