Documentation Center

How to safely shut down Apache Tomcat

Safely shutting down the Tomcat web application server is critical to maintaining the integrity of the Content Delivery database.

Overview

Whenever you have to apply a patch set to the web application server, or to Content Delivery you will have to shut down Tomcat. If the Tomcat shutdown is not done safely, the Content Delivery database may become corrupted. It may help to remove an Content Delivery server instance from the load balancer, too, as this will eliminate incoming user requests.

Do not shut down Tomcat while it is engaged in significant read/write activity to the database, including when
  • a push from a distro server is actively pushing a distribution profile, or a Content Distribution Server (CDS) is being updated from a distribution profile push.
  • a push to an aggregation server is receiving audit trails or xforms from clients, or any Content Delivery server is actively pushing audit trails or xforms to the aggregation server.
  • garbage collection is in progress (cleaning out old, or aggregated audit trails).
  • a prepare on a publication or language version from Content Delivery is in progress, a publish from Content Manager is in progress, or a publication delete is in progress (whether or not comments are deleted, too). See Log files.
  • a backup or restore is in progress.
Tomcat is constantly performing read/write activities to support the web applications that it is hosting. The goal is to shut down Tomcat during a quiet time of Content Delivery activity. To aid you in this effort, you can use the following system tools:
  • Scheduled Content Delivery processes
  • Process viewer
  • Log files
  • Automatic System Updates

Scheduled Content Delivery processes

Content Delivery can be configured to schedule various processes (aggregation, garbage collection, distro pushes, database backups) at various times and intervals. Ensure that you know these processes and when they are scheduled. Examine the C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\LiveContent\WEB-INF\conf.xml file.

Process viewer

You should examine processing activity by clicking Start > Administrative Tools > Performance Monitor. You want to ensure that there is no, or low, CPU activity. The Tomcat process (or its associated Java process) should show little, or no, input and output read/write activity.

Log files

You should examine log files to determine and predict user activity. Examine C:\Program Files\Apache Software Foundation\Tomcat 7.0\logs\localhost_access_log.nnn to determine and predict future activity, as well as who may be still logged in. Also examine tomcat7-err.nnn and tomcat7-out.nnn. If you determine Tomcat is still busy, then wait until activity has subsided.

For each process start, there should be a matching process end.

Upload starts with this message:

[Upload] Starting Upload type 'upload' for BrowseMaps-en at 15:19:50.105-04:00

Each resource being uploaded produces two log messages:
  • [Upload Resource] PUB=BrowseMaps-en type=upload bodyname= encoding= at 15:19:50.187-04:00
  • [Upload Resource] FILENAME=asiamap.ditamap extension=ditamap mime_type=xml
The upload phase ends with messages like these:
  • [Upload End] Finished Upload type 'upload' for BrowseMaps-en at 15:19:51.648-04:00
  • [Upload End] Pub BrowseMaps-en is unlocked
Prepare usually starts with messages like these:
  • [Prepare] STEP=start_prepare forBrowseMaps-en' at 15:19:57.195-04:00
  • [Prepare] Starting Prepare for BrowseMaps-en locked by 'prepare' at 15:19:57.252-04:00
Each Prepare step generates one or two messages; the final step is usually end_prepare:
  • [Prepare] STEP=end_prepare forBrowseMaps-en' at 15:20:02.621-04:00
  • [Prepare] Finishing Prepare for BrowseMaps-en at 15:20:02.655-04:00
  • [Prepare] Unlocking BrowseMaps-en; was locked by 'prepare' locking state now ''
  • [Prepare] Completed Prepare for BrowseMaps-en at 15:20:02.877-04:00
Other Prepare messages may start with these prefixes:
  • [Prepare All Pubs]
  • [Prepare Topic/Map]

Automatic system updates

Windows updates can be regularly scheduled by the user or by way of an IT policy. This sometimes leads to automatic system reboots. Restarting the system (and by extension restarting Tomcat) is not inherently dangerous unless the shutdown/restart activity does not wait for running processes to complete. This is generally an IT windows update policy setting, and you must ensure that the shutdown does not occur until Tomcat can stop properly. Failure to do so can lead to a corrupt Content Delivery database. Please consult your IT department for this setting.

Shutdown

Once you have determined that all is quiet, click Start > Administrative Tools > Services > Apache Tomcat 7 > Stop (on Linux, enter the following in a terminal window: $tomcat/bin/shutdown.sh).