Making config changes at deployment time
From ControlTier
This is part of the DukesBank portion of the ControlTier Demo
Contents |
Overview
In this demo we are going to deploy and start JBoss and then change a configuration setting to have it run on a different set of ports. This kind of configuration change is made possible by two features:
- configuration template files
- configuration setting data
This example also shows the JBossServer type coordinating the configuration cycle that includes the generation of configuration files from templates.
See also:
- Dukes Bank Provisioning JBoss instances page for information about provisioning an empty JBoss instance.
Prerequisites
This demo assumes you have completed:
Preparation
Before getting started confirm the JBossServer and Site objects are deployed to CTL.
Run the ctl-depot install command for the demo project:
$ ctl-depot -p demo -a install "Install" command running for object: (Site) developmentDukesBank . . . "Install" command running for object: (JBossServer) developmentDukesBank . . .
Your output should show the Site and JBossServer (among other objects).
Once you have completed the preparation steps, you are now ready to demonstrate the full deploy cycle.
Start JBoss
JBoss should already be running. It's always safe to run the Start command:
ctl -p demo -t JBossServer -o developmentDukesBank -c Start
begin workflow command (1/1) -> "assertServiceIsUp " ... JBoss is UP. end workflow command (1/1) -> "assertServiceIsUp "
Access JBoss instance
You should be able to see the management screen of an empty JBoss instance at http://localhost:8180/ (or your server's hostname).
JBoss configuration
As you noticed in the URL above, you access the JBoss instance via 8180.
Part of the JBoss configuration is kept in $CTIER_ROOT/demo/elements/development/dukesbank/jboss-4.0.3SP1/server/default/conf
In this directory this port is defined in a JBoss configuration file called "bindings.xml". Here's a snippet of the bindings.xml file generated for Dukes Bank from a bindings.xml template file.
This snippet shows the "ports-01" server configuration that declares "8180" as the port:
<service-bindings>
.
.
.
<server name="ports-01">
.
.
.
<binding port="8180"/>
</service-config>
.
.
.
</server>
</service-bindings>
This bindings.xml file defines the port ranges but your instance can then choose one of these configurations via the "jboss-service.xml" file. Here's a snippet of the jboss-service.xml file referring to the "ports-01" server configuration:
<server>
.
.
.
<mbean code="org.jboss.services.binding.ServiceBindingManager"
name="jboss.system:service=ServiceBindingManager">
<attribute name="ServerName">ports-01</attribute>
.
.
.
</server
Both the bindings.xml and jboss-service.xml files are generated from templates. JBossServer has a command called "Configure" that is responsible for the configuration cycle. It is during the configuration cycle that template files are used to generate working files based on input configuration data.
The template that generates the jboss-service.xml uses tokens instead of hard coded values for several parameters. Note the tokens ServerName and StoreURL. The snippet below shows two example uses of these tokens:
.
.
.
<mbean code="org.jboss.services.binding.ServiceBindingManager"
name="jboss.system:service=ServiceBindingManager">
<attribute name="ServerName">@PortConfig@</attribute>
<attribute name="StoreURL">${jboss.home.url}/server/@BaseDirName@/conf/bindings.xml</attribute>
<attribute name="StoreFactoryClassName">
org.jboss.services.binding.XMLServicesStoreFactory
</attribute>
</mbean>
.
.
.
During the Configure workflow, these tokens are replaced by the configuration setting data.
View the settings
You can examine the JBoss instance's configuration data using the Properties command:
ctl -p demo -t JBossServer -o developmentDukesBank -c Properties
Some of the output is not shown but you can note the JBossPortConfig setting value for the developmentDukesBank instance of JBoss:
[MULTI_LINE]
# developmentDukesBank [JBossServer] #
Development environment JBoss server
.
.
.
5. developmentDukesBank [JBossPortConfig]
* doc: "JBoss service bindings port configuration"
* encrypted: "false"
* name: "developmentDukesBank"
* order: "Setting"
* settingType: ""
* type: "JBossPortConfig"
* value: "ports-01"
- - -
[/MULTI_LINE]
Stop JBoss
Before making the configuration setting change shutdown the Jboss instance:
ctl -p demo -t JBossServer -o developmentDukesBank -c Stop
begin workflow command (1/1) -> "assertServiceIsDown " ... JBoss is not DOWN! Error handler caught failed command execution: developmentDukesBank[JBossServer]->assertServiceIsDown. reason: The following error occurred while executing this line: /Users/alexh/ctier/ctl/depots/demo/modules/JBossServer/commands/assertServiceIsDown.xml:35: shellscript returned: 1 Running handler command: stopServiceWrapper Workflow beginning. commands: stopService,waitforStopEvent begin workflow command (1/2) -> "stopService " ... end workflow command (1/2) -> "stopService " begin workflow command (2/2) -> "waitforStopEvent " ... end workflow command (2/2) -> "waitforStopEvent " [command.timer: 6.923 sec] Workflow completed. execution time: 6.923 sec end workflow command (1/1) -> "assertServiceIsDown "
You should no longer be able to see the management screen of the JBoss instance at http://localhost:8180/ (or your server's hostname).
Modify setting
As the Properties command showed, the port binding configuration is maintained as a setting. Go to the JBossServer instance in Workbench to view the setting:
You can edit the Setting by locating it in the "Child Dependencies" view and pressing the edit button on the right of the list.
This brings you to the edit page where you can change the value to "ports-03":
Save the change.
Run Deploy
You have changed the setting to "ports-03" so now run the Deploy command.
The Deploy workflow will take care of installing the packages, regenerate configuration and then restart the server.
ctl -p demo -t JBossServer -o developmentDukesBank -c Deploy
A sampling of the output will show the "Configure" workflow that generates the configuration files:
begin workflow command (1/4) -> "Stop " ... begin workflow command (1/1) -> "assertServiceIsDown " ... JBoss is DOWN. . . . begin workflow command (3/4) -> "Configure " ... Start: "Run the configuration cycle for the deployment." commands: Docs-Generate begin workflow command (1/2) -> "Docs-Generate " ... Copying 3 files to /Users/alexh/ctier/demo/elements/development/dukesbank/jboss-4.0.3SP1/server/default Copying /Users/alexh/ctier/ctl/depots/demo/modules/JBossServer/templates/jboss-4.0.3SP1/server/default/conf/bindings.xml.template to /Users/alexh/ctier/demo/elements/development/dukesbank/jboss-4.0.3SP1/server/default/conf/bindings.xml Copying /Users/alexh/ctier/ctl/depots/demo/modules/JBossServer/templates/jboss-4.0.3SP1/server/default/conf/run.conf.template to /Users/alexh/ctier/demo/elements/development/dukesbank/jboss-4.0.3SP1/server/default/conf/run.conf Copying /Users/alexh/ctier/ctl/depots/demo/modules/JBossServer/templates/jboss-4.0.3SP1/server/default/conf/jboss-service.xml.template to /Users/alexh/ctier/demo/elements/development/dukesbank/jboss-4.0.3SP1/server/default/conf/jboss-service.xml . . . end workflow command (1/1) -> "assertServiceIsUp " end workflow command (4/4) -> "Start "
Using the new configuration setting the JBoss server should now be bound to ports defined in "ports-03".
Login to Dukes Bank
The "ports-03" server configuration has the JBoss instance listening on 8380.
You should be able to see the management screen of an empty JBoss instance at http://localhost:8380/ (or your server's hostname).
Summary
In this demo we covered:
- Data driven configuration
Of course, you might want to return JBoss back to the "ports-01" configuration setting.



