Monday, December 11, 2017

Running Kitto through a Proxy server

Did you know you can run a Kitto application through a Proxy server? Wonder why and how? This page just added to the Kitto wiki explains everything:

https://github.com/EtheaDev/kitto2/wiki/Proxy

Don't forget to pull the latest changes from the repository.

Friday, December 8, 2017

Zero-code WebBroker support

Just a quick note to signal that Kitto2 has just gained WebBroker support, which means new deployment options such as CGI, ISAPI and Apache modules.

Kitto-only WebBroker applications

Kitto's approach to WebBroker deployment is zero-code, meaning that you just need to create a standard WebBroker project through Delphi's wizard, choose the deployment option that you require, and then in the generated project ditch the auto-created empty WebModule unit and add Kitto.WebBroker.WebModule to the uses list. That's all.

Mixing Kitto with other services in the same application

Alternatively, if you want to mix the Kitto application with other services or for any other good reason you require to keep the generated WebModule, you just add the following code to the WebModule1DefaultHandlerAction event handler or to some other web action handler:

Handled := TKWebBrokerHandler.Current.HandleRequest(Request, Response);

Also add the Kitto.WebBroker.Handler unit. By the way, this unit will be useful if you need to integrate a Kitto application into any sort of existing application (as long as it is an HTTP server), provided you can manufacture the needed TWebRequest/TWebResponse classes.

Implementation status

This has required a complete reimplementation of session management in Kitto, which is now independent from Indy, more manageable and hopefully faster. The code still needs some testing (especially look for deadlocks and race conditions) and possibly a few refinements. This is currently being done, but you can start experimenting.

Saturday, December 2, 2017

Windows Services and latest developments

Among the recent changes to our Kitto2 repo is restored support for running a Kitto application as a Windows Service, which was disabled when porting the code from Kitto's previous life and has been just reimplemented and enhanced.

Running HelloKitto as a Windows Service

If HelloKitto.exe is not run by an administrative account, it will default to running as an application. Otherwise, it will run as a service and interpret the -install and -uninstall command line switches (you can also use slashes instead of dashes) to register and unregister the service in the Service Manager. From then on, you just start and stop the service from the Control Panel (by default, it's an auto-start service but you can change this and other parameters through the new Service section in the Config.yaml file.

Note

You can run HelloKitto as an application even when running it from an administrative account, by passing the -a command line switch.

The same applies to all Kitto applications, of course. No changes needed to application code or project files.

Kitto.Start.pas

A Kitto application can run as an application or service (and soon also command line application and Linux daemon) off the same compiled executable with the same project file code. All the intricacies are encapsulated in the Kitto.Start.pas unit; you just need to call Kitto.Start as the sole code in your project file and the rest will be taken care of.

Going forward

As we add more deployment options to Kitto (mainly ISAPI and Apache module), a separate project file will be needed for each one, as Delphi project files for programs and libraries are structurally different; we will aim to keep the required code in the project file to a minimum anyway.

A huge internal refactoring has just taken place to allow new deployment options to be implemented soon in an easier way. Specifically, the TKWebServer class was split into an HTTP server class that handles requests and responses and an engine class (which is a route) than handles sessions and controls the TKWebApplication class which is the heart of a Kitto application (and itself a route). The route subsystem has been refactored as well to allow route composition through the TKWebRouteList class.