You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by chris derham <ch...@derham.me.uk> on 2011/02/16 13:46:35 UTC
Automated installer for war files
All,
I have been reading "Continuous Integration: Improving Software Quality and
Reducing Risk". It recommends having an automated installer for all
deployments, so that the everything is the same on all environments. We
typically have multiple instances of tomcat, allowing us to segregate
applications and start|stop instances in isolation. We currently set this up
manually, but I am trying to work out if we could create an automated
deployment tool such that at deployment it would
- Check for existing installation - if one found
- shutdown existing service
- remove existing service
- remove existing tomcat instance
- deploy new war, along with appropriate configuration files
- register service
- startup service
To be clear, the script could assume that tomcat was already installed - say
drop out if no CATALINA_HOME env variable set. I planned to feed it a
property file with username/password/db connection string, so we could take
the same installer and run on multiple environments without compromising the
security of passwords etc.
I can't seem to find anything included in tomcat to do this. So is the
"expected" method of deployment to manually configure multiple tomcat
instances, and then just deploy the war by hand/script? Am I missing some
key piece of software/knowledge?
I was looking at writing a script in say NSIS or something similar. Anybody
have any experience of this, or suggest a better way of doing it?
Thanks for any help
Chris
Re: Automated installer for war files
Posted by André Warnier <aw...@ice-sa.com>.
chris derham wrote:
>>
>> Can you expand a bit on the above ?
>> (That seems to be the only part which is really Windows-specific).
>> Such as, what "variable" are you talking about, defined where ?
>>
> So currently we set catalina_home and catalina_base, cd into
> <catalina_home>\bin and run
>
> service install myApp
>
> then manually run
>
> tomcat6w //ES//myApp
>
> And under the java tab, manually append to the java options
>
> -Denv=uat
>
> for example. I think that this can be scripted using tomcat6w, e.g.
> something like
>
> tomcat6w //IS//myApp --JvmOptions -Denv=uat --Startup=auto
>
> I wrote the email to just try to ascertain which way is the "most
> popular/best" way to perform this
>
>> One other thing : it seems that when you talk about "tomcat instances", you
>> are really talking about nn separate installations of Tomcat, each with its
>> own top installation directory, and each with its /bin, /lib, etc..
>> sub-directories.
>> Is that how your setup is ?
>> Or do you have one single Tomcat software directory (%CATALINA_HOME%),
>> shared by multiple running Tomcat processes (each with its separate
>> %CATALINA_BASE%) ?
>>
>> When I said tomcat instances, I meant single catalina_home with multiple
> catalina_bases. I can see that this is ambiguous - I don't know if there is
> a better term that you guys use for this, as opposed to multiple
> catalina_homes?
>
No, you are right, that was the right term. I just had a doubt, but you are doing this
"correctly".
One more question:
Above, you mention "myApp" as the name of the Service.
I guess that you mean also "myApp1", "myApp2", ... (as many different services as you have
Tomcat instances), right ?
I don't think that there is a commonly accepted or used way of doing this kind of thing.
Personally, it looks to me like you are doing this in a sensible way, considering.
Others may have a better idea.
The only thing for me is : it looks as if the only "Service setup value" which is
different from one Tomcat to the other, is this "-Denv=uat" flag.
I presume that this is something picked up later by the application.
If you could move this somewhere else (such as in the application's "context.xml", or an
<init-param> in the webapp's web.xml), and have the application picking it up from there,
then it seems to me that this would alleviate the need of manipulating the Service's
Registry parameters altogether, no ?
(and consequently also the need for stopping, re-registering and restarting the Service)
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Automated installer for war files
Posted by chris derham <ch...@derham.me.uk>.
>
>
> Can you expand a bit on the above ?
> (That seems to be the only part which is really Windows-specific).
> Such as, what "variable" are you talking about, defined where ?
>
So currently we set catalina_home and catalina_base, cd into
<catalina_home>\bin and run
service install myApp
then manually run
tomcat6w //ES//myApp
And under the java tab, manually append to the java options
-Denv=uat
for example. I think that this can be scripted using tomcat6w, e.g.
something like
tomcat6w //IS//myApp --JvmOptions -Denv=uat --Startup=auto
I wrote the email to just try to ascertain which way is the "most
popular/best" way to perform this
>
> One other thing : it seems that when you talk about "tomcat instances", you
> are really talking about nn separate installations of Tomcat, each with its
> own top installation directory, and each with its /bin, /lib, etc..
> sub-directories.
> Is that how your setup is ?
> Or do you have one single Tomcat software directory (%CATALINA_HOME%),
> shared by multiple running Tomcat processes (each with its separate
> %CATALINA_BASE%) ?
>
> When I said tomcat instances, I meant single catalina_home with multiple
catalina_bases. I can see that this is ambiguous - I don't know if there is
a better term that you guys use for this, as opposed to multiple
catalina_homes?
Thanks
Chris
Re: Automated installer for war files
Posted by André Warnier <aw...@ice-sa.com>.
chris derham wrote:
...
> safer to remove service. That way if we make any tweaks to the service
> configuration, they would be propagated to all environments. (currently we
> update the windows service to add a variable to tell the app which
> environment it is running under)
>
Can you expand a bit on the above ?
(That seems to be the only part which is really Windows-specific).
Such as, what "variable" are you talking about, defined where ?
One other thing : it seems that when you talk about "tomcat instances", you are really
talking about nn separate installations of Tomcat, each with its own top installation
directory, and each with its /bin, /lib, etc.. sub-directories.
Is that how your setup is ?
Or do you have one single Tomcat software directory (%CATALINA_HOME%), shared by multiple
running Tomcat processes (each with its separate %CATALINA_BASE%) ?
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Automated installer for war files
Posted by chris derham <ch...@derham.me.uk>.
> Maybe you should be more precise as to what exactly you want to be able to
update mechanically.
Fair question. We have different environments - test, uat and prod. We want
the environments to be the same. We install multiple tomcat instances, so we
don't typically customize the tomcat install much - just add the jdbc jars
to lib folder. Then each environment has a tomcat instance containing the
war, and a context file. The context file we change a little - typically we
replace the start with this (currently using tomcat 6.0.32)
<Context disableURLRewriting="true" useHttpOnly="true"
privileged="false" allowLinking="false" crossContext="false">
<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<!-- Uncomment this to disable session persistence across Tomcat
restarts -->
<Manager pathname="" randomClass="java.security.SecureRandom" />
Then we would add entries for resources, such as smtp and jdbc and some
entries to configure the app, e.g. so extra logging on test server, and
turning off access to test urls on production.
So our intention was to automate this all, except the initial installation
of tomcat. So when we have a new war ready to deploy, our automated build
process makes the war and makes an installer. We could then take that
installer, invoke it on the target environment. If first install, then it
would setup the service etc. If just an update, then I figured it would be
safer to remove service. That way if we make any tweaks to the service
configuration, they would be propagated to all environments. (currently we
update the windows service to add a variable to tell the app which
environment it is running under)
Apologies if nobody else is doing this - I truly assumed that this would be
a common need. I was aware of the manager app, and knew that you could call
ant tasks to deploy new apps to it. However I didn't think that the tasks
that it has would cover the whole range of installing a service etc
I also agree with your comment about "reinstalling the whole service seems
overkill to just deploy an updated war file". However without the ability to
deploy all the settings automatically via a script, I can't see how we can
guarantee that all environments are the same. Working on multiple projects,
it is just hard to keep all envs in sync all the time manually IMHO
Thanks for your suggestion
Chris
Re: Automated installer for war files
Posted by André Warnier <aw...@ice-sa.com>.
chris derham wrote:
..
>
> - Check for existing installation - if one found
> - shutdown existing service
> - remove existing service
> - remove existing tomcat instance
> - deploy new war, along with appropriate configuration files
> - register service
> - startup service
>
I do not presume to understand exactly what your requirements are, but if you are talking
about deploying/redeploying /tomcat applications/, it seems a bit drastic to remove the
whole tomcat instance just for deploying a new war.
The Tomcat Manager interface provides a programmatic way to stop an application within a
running Tomcat instance, replace the application, and restart it, all of that without need
to even stop the Tomcat instance.
At one level above, you can also stop a Tomcat instance (under Windows, probably a
Service), without having to de-register and re-register the Service.
And so on : you can also update the Tomcat software without necessarily updating the Java
JVM, and you can update the Java JVM without necessarily having to reboot the system, etc..
Maybe you should be more precise as to what exactly you want to be able to update
mechanically.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org