Page Tools:
Wiki Relationships:
Admin Tools:
Article:Warconfig
Contents |
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.
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).
Some examples
Deployingwarconfig.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/
Upgradewarconfig.py -G sample 1.2 -c testroll
Upgrade the "sample" application to version 1.2.
Watching file changeswarconfig.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 changeswarconfig.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)
Rollbackwarconfig.py -R sample 1.2 -c testroll
Rollback from version 1.2 of application to version 1.0.
Undeploywarconfig.py -U sample 1.0 -c testroll
Undeploy version 1.0 of application.
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)).
References
- [1] A copy of warconfig.py is on my blog
- [2] webapp-config
- [3] Capistrano
- [4] cfg-update
- [5] my blog
- [6] Cargo

Testing
