Creating a Service Application

The following instructions assume that you have installed Ellogon Services, and that the services code is located in ~/ellogon-apache-services. In case the services code is installed at a different location, the instructions must be adapted accordingly.

The directory structure

The provided Ellogon scripts for implementing HTTP REST services are organised into two directories: "server" and "site". The "site" folder contains scripts that can be called by clients (are exposed through the HTTP server), such as the "test.tcl" script, which reports the Ellogon version, and serves as a test script for the installation of the Ellogon services. On the other hand, the "server" folder contains scripts that will be executed each time the Apache HTTP server needs to create a new Tcl interpreter, for servicing scripts written in Tcl (such as the Ellogon HTTP REST services).

How can I split code between the two folders?

There are two ways that you can implement a service: you can assemble the service (by loading the needed packages, creating the required objects, etc.) when it is needed, process the provided input and destroy the created resources with each request (placing all code in a file inside the  "site" folder), or assemble the service (in memory) during the initialisation of the interpreter, and just call the processing part of the code when a request arrives. In such a case, code must be placed in both the "server" and "site" folders: code that creates the application must be placed in "server/conf.d", and code that uses the application to service client requests must be placed in the "site" folder.

The suggested way of writting applications, is to assemble and initialise the application with code placed in the "server/conf.d" folder, and use the application to service requests by writting a script inside the "site" folder, especially if the initialisation of the application is not efficient (like loading a 10M-entries gazetteer into memory).

Creating a simple HTTP service