Skip to content
This repository has been archived by the owner on Jan 25, 2019. It is now read-only.

Legacy applications with Tardigrade broker

Al-Muhandis edited this page Nov 28, 2018 · 5 revisions

Introduction

This document will provide all steps showing how to use Brook Tardigrade to run legacy applications based in Brook 3 or 4. In general, such applications depend on external web server and run through CGI or FastCGI. Since Brook Tardigrade provides a high-performance secure HTTP web server, it can be embedded into any VCL/FMX/LCL/console application and used as a good replacement for Apache, Nginx, IIS, Lighttpd, Mongoose, fphttpserver and so on. There are many advantages in using Tardigrade, like better performance, easy debugging, few (or any) configuration, no special permissions to handle register or kernel mode driver like http.sys, distribution of a single GNU library about 140 kB instead of distributing an entire setup or many files of a full web HTTP server.

Getting Sagui library

Sagui library is the heart of all this. It has built libraries (DLLs) for Windows 32/64 and can be easily built for other Unix based systems.

Windows

For Windows, download the packagelibsagui-1.2.0-dll.zip from this page, choose the version x86 (32 bits) or x86_64 (64 bits) and unpack it into your application directory.

Linux (Ubuntu, Debian etc)

For Ubuntu/Debian download and install

#      Install required tools.

sudo apt update  # For Debian usually: aptitude update
sudo apt install clang cmake # For Debian it can: aptitude install clang cmake

#     Download latest release

wget --continue --content-disposition https://github.com/risoflora/libsagui/archive/v1.2.0.tar.gz
tar -zxvf libsagui-1.2.0.tar.gz
# Create temporary directories to build the library
cd libsagui-1.2.0/ && mkdir build && cd build/

#     Configure, build and install.

# prepare the build scripts (please use the build summary to check if the build is OK for your system)
cmake -DCMAKE_C_COMPILER=clang -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON ..
# build / install the binary
make && sudo make sagui install/strip  # For Debian: make && make sagui install/strip
# update the LD cache on your system   
sudo ldconfig                          # For Debian just ldconfig                          

For other systems, follow these steps to build the library from scratch.

Note: there is a 'Needs packaging' entry on Launchpad to make Sagui library available on APT in next Ubuntu releases.

Installing Brook Tardigrade

Currently, Brook Tardigrade is in beta version and can be downloaded here. After downloading it, unpack and install the package BrookTardigrade.dpk for Delphi or BrookTardigrade.lpk for Lazarus. Optionally, you can test its examples just copying the Sagui library into the Examples directory.

Running the legacy application

Probably, some version of Brook will already be installed in your Lazarus IDE. Otherwise, supposing your application depends on Brook 4, this version can be downloaded here and installed via its .lpk packages. After that, got to your Brookers.pas unit and replace any already existing broker like brookfclcgibroker.pas, brookfclfcgibroker.pas, brookfclhttpappbroker.pas etc. by the Tardigrade/brooktardigradebroker.pas.

Also it must to add the new line Application.Initialize; (if it is not) before BrookApp.Run; //(or Application.Run) to the legacy code of Your lazarus project (.lpr).

Now, just run your application and voilà, welcome to the Brook Tardigrade!

Questions

If you have any doubts about the steps above and would like to test it in a already existing application, we provided the smallest example showing it in practice, and you can get it here.