0

The infamous rm -rf command is something we would rather avoid in Production, even if it's scripted. So if you have a war file named mywebapp.war and a directory its deployed to under webapps/ that is called webapps/mywebapp/ how can you force a re-deployment without using rm -rf webapps/mywebapp/ The Tomcat bug is intermittent and hard to reproduce so I'm trying to plumb the depths of community experience for tricks that are known to work.

What about:

  • Setting the access date on the war or the deployment dir and/or it's contents just prior to startup?

  • Sending a Unix signal to the Tomcat process?

  • Other?

We are kind of hidebound with the use of scripts rather than something like the Tomcat Deployment Widget so I'm looking for script-able options that will not result in a all-out rebellion. ;-)

user447607
  • 493
  • 1
  • 6
  • 9
  • Another idea: Use Maven deployment widget. – user447607 Mar 14 '13 at 19:33
  • ...mmmm not sure. We don't have any sort of manager running. – user447607 Mar 14 '13 at 19:56
  • Read Tomcat 7.0 [Automatic Application Deployment](https://tomcat.apache.org/tomcat-7.0-doc/config/host.html#Automatic_Application_Deployment). Result the manual before you start scripting. Manual deployment can be done with the [text/html-manager](https://tomcat.apache.org/tomcat-7.0-doc/manager-howto.html) (called manager-script/manager-gui). (EDIT: links changed to Tomcat7) – Freddy Jan 24 '19 at 21:52

2 Answers2

1

You can just touch your_app.war Tomcat will do redeploy right away.

If you are concerned about protecting timestamps for .war files (which is a good idea) you can keep a symlink from webapps dir to the actual location of .war file and touch the symlink.

timurb
  • 347
  • 4
  • 12
0

In your server.xml for Tomcat, you can configure the appBase to do autoDeploy="true", and unpackWARs="true".

Then if you deploy a war file, it will create the directory, and if you rename the war file, it will remove it. This isn't really recommened for production use.

Also, if you don't want to do rm -rf, just move the archive to a parent folder and then archive it or do whatever you want.

Schrute
  • 807
  • 6
  • 14
  • But setting autoDeploy and unpackWARs to true doesn't force tomcat to do redeploy on startup if the war-files has changed since that time. How do you force Tomcat to do that? – timurb Dec 07 '14 at 09:09