TorQ Installation Script

Sander Roomus datablog, kdb+, TorQ Leave a Comment

Background

Historically, TorQ and its corresponding packages have had a method of installation that meant unzipping the packages and copying them on top of each other. That was an easy method, and is still fine for test or trial applications. For production applications we have tended to separate TorQ, the application that sits on top of it and the data into separate locations. To formalise this, we have created an installation script. The advantages of the installation script compared to the previous approach:

  • Ease of use
    For new installation just copy two lines as shown below to the directory you want your latest version of TorQ and TorQ application to be deployed and then run TorQ.
  • Version control and rollback
    The updated folder structure makes it easy to update TorQ versions to either move forward or rollback from releases. If something isn’t working then pointing the version soft link to the latest working version.
  • More granular configuration
    Can rename processes and ports to showcase primary (pri) and disaster recovery(dr) uses with the addition of environment-specific variables. Example below.
  • Splitting out data and code
    Can now have the hdb and other data folders (logs,tplogs, etc) in another directory or another drive. The codebase can live in one place and the data folder can be easily pointed to another drive.

Layout on disk

After the installation the layout on disc will be the following:

Install_structure
Folder structure after installation

The script will create a folder for every TorQ and TorQ application versions.
Installing a newer version of TorQ a new version folder is added and the latest soft link is pointed toward the most recent TorQ folder. If rollback is necessary due to version upgrade then can repoint the latest soft link toward the most recent working version.

Basic Instructions to install TorQ-FSP

  • Get the TorQ-FSP latest installation script and download it to the directory where you want your codebase to live.
wget https://raw.githubusercontent.com/AquaQAnalytics/TorQ-Finance-Starter-Pack/master/installlatest.sh
  • Then run the following line in the same working directory
bash installlatest.sh

That is the most basic installation of TorQ and one of its applications.
All the TorQ packages that have the installlatest.sh script on GitHub work with the install script.

Advanced Instructions to install TorQ-FSP

An example with extra parameters, changing the data folder directory and configuring environment variables.

  • Get the TorQ-FSP latest installation script and download it to the directory where you want your codebase to live.
wget https://raw.githubusercontent.com/AquaQAnalytics/TorQ-Finance-Starter-Pack/master/installlatest.sh
  • Configure the environment-specific file. An example file called env_pri.sh is show below.
# This does replacements in bin and TorQApp directories only
# Replace KDBBASEPORT in all .sh scripts
find $1 -type f -name "*.sh" -exec sed -i "s/export KDBBASEPORT=.*/export KDBBASEPORT=7373/g" {} \
# Replace hdb1 in all .csv files 
find $1 -type f -name "*.csv" -exec sed -i "s/hdb1/hdb_pri/g" {} \;
  • Create a second environment script for the secondary or disaster recovery environment called env_dr.sh:
# This does replacements in bin and TorQApp directories only
# Replace KDBBASEPORT in all .sh scripts
find $1 -type f -name "*.sh" -exec sed -i "s/export KDBBASEPORT=.*/export KDBBASEPORT=3535/g" {} \;
# Replace hdb1 in all .csv files 
find $1 -type f -name "*.csv" -exec sed -i "s/hdb1/hdb_dr/g" {} \;
  • Then change installlatest.sh script ending to look like below:
bash installtorqapp.sh --torq TorQ-$torq_latest.tar.gz --releasedir deploy_pri --data fsp_data_pri --installfile TorQ-Finance-Starter-Pack-$torq_fsp_latest.tar.gz --env env_pri.sh

bash installtorqapp.sh --torq TorQ-$torq_latest.tar.gz --releasedir deploy_dr --data fsp_data_dr --installfile TorQ-Finance-Starter-Pack-$torq_fsp_latest.tar.gz --env env_dr.sh
  • Then run the following line in the same working directory as the install script
bash installlatest.sh

This will install two separate instances of TorQ and its application on the same server for different configurations:

  • Pri running on stack starting with 7373
  • Dr running on stack starting with 3535

Running the TorQ stacks can be seen in the diagram below:

Example TorQ stacks in different environments.

The databases above are separated with the –data installation parameter. In this example, one database is stored in fsp_data_pri and the other in fsp_data_dr.

The env parameter can be extended to set all the process names for an environment and also the required variables for feeds, or any other environment specific configurations.

Further functionality

Instead of a .tar.gz file for TorQ, it also accepts the full path to an unpacked TorQ. This way multiple TorQ applications can use the same TorQ basecode if required. The script accepts both full path parameters and relative path parameters for all command line arguments.

Further technical documentation and updates can be found here.

Version control

The installation script is currently tested to work with the below versions, and will likely work with some earlier versions:

  • TorQ v3.7.0 or higher
  • TorQ-FSP v1.9.0 and higher
  • TorQ-Crypto v1.0.0 and higher
  • TorQ-TAQ v1.0.0 and higher
Sander RoomusTorQ Installation Script

Leave a Reply

Your email address will not be published. Required fields are marked *

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax