Screencast: Configuring a Service with your start and stop scripts

From ControlTier

Jump to: navigation, search

Contents

Overview

See the screencast

This page accompanies the screencast showing how to configure startup and shutdown control scripts for an instance of the Service type.

Hooking in your scripts

You can attach your scripts to a Service by registering them as a setting of your Service resource. The XML file below describes a Service named "tomcat1" and four scripts (hypothetically) residing in $HOME/bin.

Each script is registered as a setting that exports an attribute used by the Service commands to look up the location of your script.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE project PUBLIC "-//ControlTier Software Inc.//DTD Project Document 1.0//EN" 
    "project.dtd">
<project>
  <!--
      **
      ** Defines path to the Service control scripts metadata
      **
  -->
  <setting type="ServiceStartScript" name="tomcat1" 
           description="The script used by startService" 
           settingValue="${env.HOME}/bin/tomcat-start.sh" settingType="script"/>
  <setting type="ServiceStopScript" name="tomcat1" 
           description="The script used by stopService" 
           settingValue="${env.HOME}/bin/tomcat-stop.sh" settingType="script"/>
  <setting type="ServiceIsUpScript" name="tomcat1" 
           description="The script used by assertServicesIsUp" 
           settingValue="${env.HOME}/bin/tomcat-isup.sh" settingType="script"/>
  <setting type="ServiceIsDownScript" name="tomcat1" 
           description="The script used by assertServicesIsDown" 
           settingValue="${env.HOME}/bin/tomcat-isdown.sh" settingType="script"/>
  <!--
      **
      ** Defines the Service metadata
      **
  -->
  <deployment 
      type="Service"
      name="tomcat1" 
      description="The Tomcat deployment." 
      installRoot="/demo/apache-tomcat-5.5.26" 
      basedir="/demo/apache-tomcat-5.5.26">

      <!-- 
        **
        ** References the scripts to be run by the Service lifecycle commands 
	      **
	    -->
     <resources>
      <resource name="tomcat1" type="ServiceStopScript" />
      <resource name="tomcat1" type="ServiceStartScript" />
      <resource name="tomcat1" type="ServiceIsDownScript" />
      <resource name="tomcat1" type="ServiceIsUpScript" />
     </resources>
  </deployment>

</project>

The bold text represents your procedure defined insinde a script. The italicized text shows a convention that uses the Service's name ("tomcat1") as a the setting object's name. This acts as a visual key to help show the association between them.

The graphic above describes the mapping of Service resource to the settings that represent the four scripts.

Load Resources

The resource definitions can be loaded via ProjectBuilder using the load-resources command:

ctl -p project -m ProjectBuilder -c load-resources -- -filename /path/to/metadata.xml

With the resources registered to the repository, the last step is to prepare CTL via ctl-project.

ctl-exec -- ctl-project -a install

Execute the service control commands

CLI execution

To run a command from your utility you'll use the following form:

ctl -p project -t Service -r tomcat1 -c command

To run the "assertServiceIsUp" command for the "tomcat1" Tomcat server on the local host run:

ctl -p demo -t Service -r tomcat1 -c assertServiceIsUp

...or to run the "assertServiceIsUp" command on nodes tagged "tomcats" in the project named "default" run:

ctl -I tags=tomcats -p demo -t Service -r tomcat1 -c assertServiceIsUp

You might recall that assertServiceIsUp command is actually used by higher level workflow commands. You can call assertServiceIsUp via the Status command like so:

ctl -p demo -t Service -r tomcat1 -c Status
Personal tools
Namespaces
Variants
Actions
Navigation
Communication
Development
Toolbox
Print/export