Preparing and Deploying a WildFly server to execute SPADE

This article explains how to prepare and deploy a WildFly server so that is can be used by the "vanilla" version of SPADE.

Introduction

The current "vanilla" version of SPADE, nest-spade-war, is configured to run in a WildFly server. Therefore, in this article, you will learn how to prepare and deploy such a server. If you already have one running then you may be able to skip this section, though a brief glance at it may be useful to make sure your current server behaves as expected.


NOTE: These instructions are for a WildFly 9.0.2 installation on Redhat 6.7 or one of its derivatives. Other versions of the application and OS may need modifications to be successful.


Installation the Basic WildFly server

To start with, you can simply download the server and make sure it runs on your system. The following commands do just that, but you will need to copy the set_node_id.sh script into the ~/server/scripts directory. Once the server is running you will see the last line containing "WildFly Full 9.0.2.Final (WildFly Core 1.0.2.Final) started", you can then shut it down using CTRL-C.

mkdir -p ~/server/downloads
mkdir -p ~/server/scripts
mkdir -p ~/spade/h2
# Copy set_node_id.sh into the ~/server/scripts directory
cd ~/server/downloads
wget http://download.jboss.org/wildfly/9.0.2.Final/wildfly-9.0.2.Final.tar.gz
cd ~/server
tar zxvf downloads/wildfly-9.0.2.Final.tar.gz
cd ~/server/downloads
wget http://nest.lbl.gov/products/spade/downloads/3.0.0/spade-wildfly902.tgz
cd ~/server/scripts
tar zxvf ../downloads/spade-wildfly902.tgz
cd
. ~/server/scripts/wildfly902/set_node_id.sh 
cd ~/server/wildfly-9.0.2.Final
bin/standalone.sh -server-config standalone.xml

Now that the basic server is installed you need to customize it for SPADE.

Customizing the DataSource and Transaction Timeout

SPADE uses a database to store information about the files it handles. Therefore the WildFly server needs to be modified to provide access to a suitable database. In order to run the example scenarios you can use the inbuilt ExampleDS that is provided with the WildFly server. By executing the script set_timeout_and_db.sh, which you will should to copy into the ~/server/scripts directory, you will change the default setting for the ExampleDS to place it in the ~/spade/h2 directory and simplify its use with the h2console application you will be using later. The script also change the default transaction timeout to be 1 hour as the default 5 minutes can be too short and cause transactions to be aborted while they are still valid.


NOTE: For production you should use a production quality database as outlined here


cd ~/server/downloads
wget http://nest.lbl.gov/products/spade/downloads/3.0.0/spade-wildfly902.tgz
cd ~/server/scripts
tar zxvf ../downloads/spade-wildfly902.tgz
cd
. ~/server/scripts/wildfly902/set_timeout_and_db.sh

You are now ready to consider how you want to deploy the WildFly server.

Setting up the WildFly server to run as a Service

Under normal conditions SPADE should always be running, waiting for the next bundle of files to be transferred or received, therefore it makes sense to set WildFly server to run as a system service. However, as the user running SPADE may not have root privileges, the changes below to the default WildFly server files are designed to enable that user, or the system, to manage the service.

The wildfly-as.conf file, which manages the service configuration, needs modification in order to use the user's area that than the system's one. The following does that modification (as before the modify_conf.sh script should be copied into the ~/server/scripts directory).

. ~/server/scripts/wildfly902/modify_conf.sh

The wildfly-init-redhat.sh file, which does the actual launch of the service, also needs modification so that is can be executed either as the user or as root. The following does that modification (as before the modify_redhat-init.sh script should be copied into the ~/server/scripts directory).

. ~/server/scripts/wildfly902/modify_redhat-init.sh

Once that file has been modified you can create the cervice script running the following sets of commans. (The first set of commands are only needed if you do not already have a ~/bin directory that is not in your PATH variable.)

mkdir -p ~/bin
cat >> ~/.bash_profile << EOF
PATH=\${HOME}/bin:\${PATH}
export PATH
EOF

. ~/.bash_profile
. ~/server/scripts/wildfly902/create_service.sh

The ~/bin/wildfly file can, if you wish, run chkconfig as the host's system adminstrator so that it can be used as a standard service for a starting and stopping the service.


NOTE: As the service calls a script in a user account, that user account must be as secure as the root one.


In order to test that everything was modified correctly run the following two lines.

touch ~/server/wildfly-9.0.2.Final/standalone/log/console.log
tail -f ~/server/wildfly-9.0.2.Final/standalone/log/console.log

Now open a second window on the server's host and execute the following command.

wildfly start

You should see, in your original window, that WildFly server is starting. Once that has completed, then running the following command will stop it.

wildfly stop

Your WildFly server in now ready to run the SPADE application.