C Application Server intended for business logic processing
C Other
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Locke is a C Application Server intended for scalable business rules processing.
The name of the project was a tribute to [John Locke, http://en.wikipedia.org/wiki/John_Locke].

Locke is a general purpose application server that allows you to easily create and distribute applications that run onto it. A Locke Application is a library made using the Locke API that contains the business rules specific to you app. Once deployed in Locke server, Locke will listen to a TCP port and the application methods will automatically be called whenever a request is made to the server. At this point, it supports only HTTP and Socket requests, but web services and REST support is planned for a near future. 
Each application on Locke runs on a different process, so if you accidentaly make any mistake on your code, it will not turn the entire app server down, just your application. Also, Locke supports automatic application restarts in this cases, by implementing a watchdog thread in the server process.

At this moment, Locke only support makefiles and doesn't use autoconf, automake, sconf, cmake or anything like this. However, if you have a working version of glib installed in your system, this shouldn't be a problem.
The Makefile was made to run on any Linux machine, but you can easily change the compile flags on $LOCKE_SRC/Makefile.common to support other platforms. 
The supported make targets are: clean, all and dist. Use 'make dist' to generate the binary distro.

Folder Structure
To start using Locke, the easiest way is to install the dependencies on your machine, download the binary distro and unpack it using the following command:
tar -zxvf locke.tgz -C DEST_FOLDER
where DEST_FOLDER is the one where you want the server installed. Point the environment variable LOCKE_HOME to this DEST_FOLDER.
The binary distro contains the following folder structure:
- / = The root folder of the distro. You can set the LOCKE_HOME environment variable to set this folder manually
- /api = folder that contains API header files you should include when creating your application
- /autodeploy = deploy folder. Just copy your application to this folder and Locke will automatically load it.
- /plugins = folder where service plugins are deployed to. Service plugins are DLL files that register a new service kind to be supported by the server.
- /config = general configuration files. Contains config which is not application specific.
- /documentation = server detailed docs
- /log = log files generated when you run the application 
- /var = folder used by the server to store persistent data, when aplicable
- /start_locke.sh = server start up script. Run it to start the server
- /stop_locke.sh  = server stop script. Run it to stop a running server

Application folder structure
A valid Locke application should follow this rules:
- it should be a folder that contains a .cfg file and a .so/.dll file
- the name of the .cfg file, the .so file and the folder's name should all be the same.
- Just put the app folder in the server autodeploy dir and the deploy will be made. If you `touch autodeploy/appfolder` when the server is running, a hot re-deploy is performed. 

Creating your first application 
Just look at the sample_apps folder to see how they were done. 
Basically, these are the rules your app should follow: 
- You need to generate a library file. Your app is not a standalone executable.
- You should include header files located in the api folder
- You don't need to link your library against any other. Just including the header files is fine.
- Your application should have exactly the same methods (same name and prototype) the sample apps have. Locke find the right methods by their name.

Getting more help 
Subscribe to our mailing list to ask for additional questions. Feel free to ask for new features too. :D
Subscribe at: http://groups.google.com/group/locker-server