Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

You ever want to run multiple instance of tomcats with the same install base, but tired of copy and setup server.xml file? Attached are couple Groovy scripts that create new server instances, and a tool to quickly setup a new Groovlet webapp.

...

NewTomcatInstance.groovy

Assume you have installed Tomcat6 or Tomcat5 in /opt/tomcat directory.

Code Block
none
none
ztoy:~/s zemian$ ./new_tomcat_instanceNewTomcatInstance.groovy /opt/tomcat mytomcat
Create new instance dir /opt/tomcat/instances/mytomcat
Create server.xml file with httpPort 8081, httpPort 8081
Create tomcat-user.xml file with manager role user.
Create catalina-mytomcat.sh file
Create ROOT webapp
Create ROOT webapp web.xml
Create ROOT webapp index.jsp
Done.
To Start Server: /opt/tomcat/bin/catalina-mytomcat.sh start
To View Browser: http://127.0.0.1:8081

...

Code Block
none
none
ztoy:~/s zemian$ ./delete_tomcat_instance.groovy /opt/tomcat mytomcat

...

NewWebapp.groovy

This script will create a new webapp directory structure with all the Groovlet setup ready.

Code Block
none
none
ztoy:~/s zemian$ ./new_webappNewWebapp.groovy /opt/tomcat/instances/mytomcat/webapps mywebapp
Create webapp
Copy groovy jar to lib
     [copy] Copying 1 file to /opt/tomcat/instances/mytomcat/webapps/mywebapp/WEB-INF/lib
Create webapp web.xml
Create webapp index.gsp
Create webapp mysqlreport.groovy
Create webapp mysqlreport.gsp
Done.

...