2.12. Creating Another Environment

In this section, we will create a second environment named 'uat'. We will then deploy and run another instance of the HelloServer application within this environment.

Run the following commands to create the 'uat' environment and deploy the jdk and helloserver bundles. When you are prompted for port number during the helloserver installation, choose '31002' to avoid conflicting with the first instance of helloserver. Again, use your jdk version in place of 1.5.0_07.

bw envcreate $HOME/works/environments/uat
bw deploy $HOME/works/bundles/jdk/1.5.0_07 $HOME/works/environments/uat
bw deploy $HOME/works/bundles/helloserver/1.0 $HOME/works/environments/uat

During the deployment of the helloserver bundle, configuration files are modified based on user input and the deployment directory. To see how this works, you can look at the install.sh script inside the actions directory of the helloserver bundle ($HOME/works/bundles/helloserver/1.0/bundle/actions/install.sh). This script shows some of the functions built into BundleWorks.

Now that we have a second environment containing helloserver, we will see a change in the output of bw whereis helloserver. The output will now show the second deployment of this bundle.

$ bw whereis helloserver
Available
   /home/admin/works/bundles/helloserver/1.0
Deployed
   /home/admin/works/environments/dev (/home/admin/works/bundles/helloserver/1.0)
   /home/admin/works/environments/uat (/home/admin/works/bundles/helloserver/1.0)

Finally, we want to run and test this new instance of helloserver. To do this, we must first switch to the new environment with the use command:

$ use uat

To verify, use the bw which command to see which helloserver is being used:

$ bw which helloserver
/home/admin/works/environments/uat (/home/admin/works/bundles/helloserver/1.0)

To run and test the 'uat' instance of helloserver, type:

helloserver start
helloserver hello

You can also verify with netcat or telnet using the 'uat' port of 31002:

nc localhost 31002
-or-
telnet localhost 31002