Project description at initialization time
The ctl tool is a generic application control script which can be used to start/stop or query the status of virtually any application running on a host. It is not a script to start desktop applications but to maintain server applications usually called 'daemons'. I initally wrote this tool for the company I am working for and now I am already done with my negotioations to make it Open Source.
The easiest way to describe most of its features will be an example. The following example shows how to control JBoss using ctl.
CTL usage (usage screen):
<handler> A space-separated list of handlers to apply the action
As you can see the tool supports start, stop, restart, status, maint, nomaint, critical, notcritical, list actions which are pretty much self-descriptive.
The tool comes along with an application framework. The framework structure
looks like this:
Additionally envsetup sets a bunch of variables like $RUN, $LIB, $CONF
$TOOLS pointing to the appropriate application directories.
Each handler can have its own 'env' file. In my example there is a 'jbossenv' file. This file is sourced before JBoss is started to set up handler-specific environment. It might also contain environment variables used to configure ctl to re-direct the stdout specifically for this handler for example.
If a startup procedure is too complicated or very application specific it is possible to write a handler-specific start() and shutdown() shell function (to be simply defined in the env file). Alternatively it is possible to write a <handler>start or <handler>stop script which will be run instead of the internal startup routines in case they are present. This still allows using 'ctl start <handler>' to run the handler.
This framework dramatically increases application handling unification. A supporter can simply log on to a system and use 'ctl status all' to see the status of all handlers for this application. He/she even does not have to know the handler names or how they are started/stopped since a simple 'ctl list all', 'ctl start <handler|all>', 'ctl stop <handler|all>' will work everywhere.
Additionally it is extremely simple to write startup scripts at /etc/init.d/ which are completely generic (the script does not even have to know the appliction path or name).
In clustered environments you would have to buy very expensive application-agent scripts specific for each application since each application is handled uniquely. Using ctl a simple ctl-agent can be used for all applications. This dramatically decreases clustering costs and simplifies the environment. I even wrote a script which can simulate a monitoring cluster. It runs in the background and restarts crashed applications automatically. Since it uses ctl there is not even a configuration needed for this tool to work in different environments.