2.11. Running HelloServer

We are ready to run the helloserver instance that we created in the previous section. To do this, we need to tell BundleWorks which environment we want to use. This is done with the use command. The use command will load any loadable bundles within an environment and create aliases to the excutable ones so that we can run them more easily.

To use our 'dev' environment, type use dev. You will not see any output, but you can use the bw list used command to verify.

$ use dev
$ bw list used
/home/admin/works/environments/dev
   helloserver -> /home/admin/works/bundles/helloserver/1.0
   jdk -> /home/admin/works/bundles/jdk/1.5.0_07

The bw which command is similar to the UNIX 'which' command. In BundleWorks, it will show which bundle is currently 'in use'. For example, typing bw which jdk will find the jdk currently in use and display output similar to the following:

$ bw which jdk
/home/admin/works/environments/dev (/home/admin/works/bundles/jdk/1.5.0_07)

In the 'dev' environment, the 'helloserver' bundle is executable, so the use command that we issued earlier created an alias for executing this application by name. If you type alias, you should see the following in your list of aliases:

alias helloserver='bw "/home/admin/works/environments/dev/helloserver"'

We can use this alias to start helloserver, by issuing the command below. If you are starting helloserver for the first time, some configuration files will be archived. This is an example of BundleWorks' automatic versioning of configuration.

helloserver start

Verify that helloserver is running by connecting to it using either netcat or telnet. You will need to have netcat or telnet installed for these commands to work:

nc localhost 31001
-or-
telnet localhost 31001

You should see a "Hello." message displayed.

You can issue other commands using the 'helloserver' alias. Try the following:

helloserver stop
helloserver status
helloserver restart

These commands are standard BundleWorks commands. BundleWorks also allows a bundle to define custom commands. In the sample helloserver bundle, the 'hello' command is implemented (using a script named 'hello.sh' inside the bundle's 'actions' directory). This 'hello' command runs a test client which connect to the HelloServer application on the configured port. It provides another way to see if the application is operating properly.

Execute this 'hello' command using the following command. You will see the same 'Hello.' message displayed earlier.

helloserver hello

You can view the history of the helloserver deployment (as well as any other BundleWorks object), by using the bw history command. You can also call the history command through the 'helloserver' alias as follows:

helloserver history

That will show the history of the helloserver deployment inside the 'dev' environment. To see the history of the helloserver bundle itself, type the following:

bw history $HOME/works/bundles/helloserver/1.0