Tomcat Manager Shell

I find Tomcat's Manager App's text interface very useful when ssh'ing into a headless Tomcat server. I created this little shell client so I don't have to remember the raw URL API.

Download

Walkthrough

Here is a little example session to demonstrate what tomcat-manager looks like.

$ tomcat-manager help
USAGE:

   tomcat-manager
   tomcat-manager COMMAND [OPTIONS ...]

COMMANDS:

   ---

   list
      List the context paths of all currently installed web applications.

   start CONTEXT_PATH ...
      Start the web application attached to CONTEXT_PATH.

   stop CONTEXT_PATH ...
      Stop the web application attached to CONTEXT_PATH.

   reload CONTEXT_PATH ...
      Reload the Java classes and resources for the web application attached to
      CONTEXT_PATH. This is not equivalent to a stop followed by a start.

   deploy WARFILE [CONTEXT_PATH]
      Install and start a new web application attached to CONTEXT_PATH, based on the
      contents of the web application archive found at the specified path WARFILE.

      If CONTEXT_PATH is not specified then it is constructed from WARFILE, e.g.
      WARFILE=/tmp/webapp.war -> CONTEXT_PATH=/webapp

   undeploy CONTEXT_PATH ...
      Shutdown and remove the web application attached to CONTEXT_PATH, and remove
      the underlying WAR file or document base directory.

   resources
      Enumerate the available global JNDI resources.

   serverinfo
      Display system OS and JVM properties.

   expire CONTEXT_PATH [IDLE]
      List session idle timeinformation about the web application attached to context
      path CONTEXT_PATH. If IDLE is specified, expire sessions for the CONTEXT_PATH
      which were idle for at least IDLE minutes.

   ---

   startup
      Start Catalina.

   debug
      Start Catalina under JPDA debugger.

   shutdown
      Stop Catalina, waiting up to 5 seconds for the process to end.

   kill [-SIGNAL]
      Kill Catalina with 'kill -TERM' or if -SIGNAL is specified .e.g. 'kill -9'

   version
      What version of tomcat are you running?

   ---

   help
      Print this help.

When tomcat-manager is called without arguments it will start in an interactive subshell. This saves a little typing because all the commands are directly available and also has the advantage of context-path tab completion.

$ tomcat-manager
Type 'help' to show list of commands.
tomcat-manager>

Let's show the list of currently deployed webapps.

tomcat-manager> list
context_path                   status    sessions docbase
------------                   -------   -------- -------
/                              running          0 ROOT
/examples                      running          0 examples
/host-manager                  running          0 host-manager
/manager                       running          0 manager
/docs                          running          0 docs

If we stop two webapps and deploy a new one...

tomcat-manager> stop /examples /docs
OK - Stopped application at context path /examples
OK - Stopped application at context path /docs
tomcat-manager> deploy /tmp/demonstration.war 
OK - Deployed application at context path /demonstration

...the list now looks like this:

tomcat-manager> list
context_path                   status    sessions docbase
------------                   -------   -------- -------
/                              running          0 ROOT
/examples                      stopped          0 examples
/host-manager                  running          0 host-manager
/demonstration                 running          0 demonstration
/manager                       running          0 manager
/docs                          stopped          0 docs