Article:Warconfig

Contents

Edit

What is warconfig?

Warconfig[1] is a tool for managing war files. It is based on a few different tools in the Open Source community, including webapp-config[2], capistrano[3], and cfg-update[4]. By combining the features of these tools, one should be able to do the following with a war file:

  • Deploy
  • Undeploy
  • Upgrade
  • Rollback deploy
  • Manage configuration changes within a war file

Most of these functions should be straightforward. Configuration management may be a little confusing. If you are familiar with Gentoo, then you know about the etc-update tool which shows configuration differences upon updating applications and allows one to selectively merge said changes. Likewise if you have customized a war file (one example may be changing jdbc connection parameters), and then upgraded versions to vanilla war file (and forgot to make the jdbc changes), this tool would allow you to see a "diff" of the war file contents, so you can easily update/merge where necessary.

Edit

More details

Upon deploying a war file using warconfig, some metadata is stored in the filesystem (/var/db/jwebapps). Some of the metadata that is stored is the warfile location, version, previously deployed information as well as files to monitor for changes within a war file. This meta data allows for easy rollback and allows one to track changes within war files. Imitating the /proc filesystem (on linux) and the /var/db cache data on gentoo linux, the metadata consists of filenames and file contents which correlate to key, value pairs respectively.

The tool assumes that applications will be layed out in a consistent manner in the filesystem when they are installed. (Note that I'm distinguishing between installing an application, and deploying an application (like webapp-config). Install means that the files for the app are on the file system, but not necessarily deployed in an application server.) But one should be able to provide an option to just point to a war file, if they are not in a well defined "install" directory (currently /usr/share/jwebapp/APP/VERSION/app.war).

Edit

Some examples

Deploying
warconfig.py -D sample 1.0 -c testroll

This deploys the 1.0 version of "sample" application under the context path of "testroll". If tomcat is running I should be able to access this app by hitting http://localhost:8080/testroll/

Upgrade
warconfig.py -G sample 1.2 -c testroll

Upgrade the "sample" application to version 1.2.

Watching file changes
warconfig.py -P index.jsp,WEB-INF -c testroll

Tell the tool to keep track of changes to the index.jsp file and the contents of the WEB-INF directory in the sample application war file.

Show file changes
warconfig.py --changes -c testroll

Show (in unified diff) the changes between versions 1.0 and 1.2 for the index.jsp file and all files under the WEB-INF directory. (In process of being implemented)

Rollback
warconfig.py -R sample 1.2 -c testroll

Rollback from version 1.2 of application to version 1.0.

Undeploy
warconfig.py -U sample 1.0 -c testroll

Undeploy version 1.0 of application.

Edit

Caveats

This has only been tested on a Gentoo Linux box, with tomcat 5.5. Assumming other J2EE app servers support rollback, implementing functionality for additional servers should consist of subclassing the Application class.

This tool has been in development for less than a week. Feedback is welcome.

Python. Yes this is a war configuration tool written in python! Some reasons are:

  • most Gentoo tools are written in python (though this tool isn't necessarily meant to be Gentoo specific, much like webapp-config).
  • Most (all) linux distros ship with python. (Unices are another question)
  • Python is cross platform. This should be able to run on windows without many changes (change some directories and change symlinks to copies...)
  • Python is a "scripting" language and this is a script
  • I like python ;)

Why didn't I just use cargo[6]? I briefly played with cargo. Cargo seems to be targetted towards programmers and testers. Warconfig is targetted towards admins. Perhaps if one is interested in manipulating wars from ant/maven, cargo is the way to go. But cargo didn't provide any commandline interface, and I'm not doing anything (currently) that requires having access to the java api of the containers. I'm basically copying/symlinking files. (It could be done with a shell script, but that would make it harder to maintain (IMO) and not work on windows (without cygwin, which isn't really an option for me)).

Edit

References

MediaWiki

This page has been accessed 4,639 times.

This page was last modified 22:26, 4 August 2006.