Skip to content
A command line tool and python library for managing a tomcat server
Python Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs Switch doc theme from ‘alabaster’ to ‘sphinx_rtd_theme’ Dec 1, 2019
src/tomcatmanager Clean up method signatures Feb 1, 2020
tests Fix some pylint warnings Dec 1, 2019
.appveyor.yml Update to test in Python 3.8 and drop Python 3.4 Dec 1, 2019
.gitignore
.travis.yml Update to test in Python 3.8 and drop Python 3.4 Dec 1, 2019
CHANGELOG.rst Update to 1.0.0 and Production Feb 1, 2020
CONTRIBUTING.rst More improvements for testing against a real server Dec 1, 2019
LICENSE
README.rst Drop support for python 3.4, which is end-of-life May 17, 2019
build-pyenvs.sh Updates to test against python3.8 Nov 30, 2019
conftest.py Clean up linting suggestions on tests May 19, 2018
pytest.ini Move code into ‘src’ directory. #72 Jul 16, 2018
setup.py Update to 1.0.0 and Production Feb 1, 2020
tasks.py Documentation cleanup Dec 1, 2019
tox.ini Oops, forgot sphinx_rtd_theme in tox.ini Dec 1, 2019

README.rst

tomcatmanager

latest version python license build status build status code coverage Documentation Status

If you use Apache Tomcat for any sort of development work you’ve probably deployed lots of applications to it. There are a several ways to get your war files deployed:

Here's another way: a command line tool and python library for managing a Tomcat server.

What Can It Do?

This package installs a command line utility called tomcat-manager. It's easily scriptable using your favorite shell:

$ tomcat-manager --user=ace --password=newenglandclamchowder \
http://localhost:8080/manager deploy local sample.war /sampleapp
$ echo $?
0

There is also an interactive mode:

$ tomcat-manager
tomcat-manager>connect http://localhost:8080/manager ace newenglandclamchowder
--connected to http://localhost:8080/manager as ace
tomcat-manager>list
Path                     Status  Sessions Directory
------------------------ ------- -------- ------------------------------------
/                        running        0 ROOT
/sampleapp               stopped        0 sampleapp##9
/sampleapp               running        0 sampleapp##8
/host-manager            running        0 /usr/share/tomcat8-admin/host-manage
/manager                 running        0 /usr/share/tomcat8-admin/manager

And for the ultimate in flexibility, you can use the python package directly:

>>> import tomcatmanager as tm
>>> tomcat = tm.TomcatManager()
>>> r = tomcat.connect(url='http://localhost:8080/manager',
... user='ace', password='newenglandclamchowder')
>>> tomcat.is_connected
True
>>> r = tomcat.stop('/someapp')
>>> r.status_code == tm.status_codes.ok
False
>>> r.status_message
'No context exists named /someapp'

Installation

You'll need Python >= 3.5. Install using pip:

$ pip install tomcatmanager

Works on Windows, macOS, and Linux.

Tomcat Configuration

This library and associated tools do their work via the Tomcat Manager web application included in the Tomcat distribution. You will need to configure authentication in tomcat-users.xml with access to the manager-script role:

<tomcat-users>
  ...
  <role rolename="manager-script"/>
  <user username="ace" password="newenglandclamchowder" roles="manager-script"/>
  ...
</tomcat-users>

Features

The tomcat-manager command line tool supports the following commands:

  • deploy - deploy a war file containing a tomcat application in the tomcat server
  • redeploy - remove the application currently installed at a given path and install a new war file there
  • undeploy - remove an application from the tomcat server
  • start - start a tomcat application that has been deployed but isn't running
  • stop - stop a tomcat application and leave it deployed on the server
  • reload - stop and start a tomcat application
  • sessions - show active sessions for a particular tomcat application
  • expire - expire idle sessions
  • list - show all installed applications
  • serverinfo - show information about the server, including tomcat version, OS version and architecture, and jvm version
  • status - show server status information in xml format
  • vminfo - show diagnostic information about the jvm
  • sslconnectorciphers - show ssl/tls ciphers configured for each connector
  • threaddump - show a jvm thread dump
  • resources - show the global jdni resources configured in tomcat
  • findleakers - show tomcat applications that leak memory

Documentation

Complete documentation is available at http://tomcatmanager.readthedocs.io/en/master/

You can’t perform that action at this time.